Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions .github/skills/openapi-non-generated-only/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
name: openapi-non-generated-only
description: 'Use when the user asks to modify code while avoiding generated files, OpenAPI generated code, asks do not touch generated files, or asks to fix npm run build / npm run test / npm run lint:all. Enforce edits only in non-generated files and always run lint, build, then test after each change.'
user-invocable: true
---

# OpenAPI Non-Generated Only

## Goal

Apply requested changes while editing only non-generated files.

## Rules

1. Never edit files generated by OpenAPI Generator.
2. Treat a file as generated if at least one condition is true:

- It contains: `NOTE: This class is auto generated by OpenAPI Generator`.
- It is in generated folders such as `src/api/` or `src/model/`.
- It is listed in `.openapi-generator/` metadata as generated output.

3. Prefer editing wrapper or handwritten layers, for example:

- `src/core/**`
- `src/upsun.ts`
- `src/index.ts`
- `tests/**`
- `README.md` and scripts/config when relevant

4. If a fix appears to require generated files, do not edit them directly:

- Update non-generated adapters/types/tests first.
- If still blocked, ask for confirmation to regenerate from spec/templates.

5. Preserve existing public API behavior unless the user explicitly asks for a breaking change.
6. When the request is to fix npm run build, npm run test, or npm run lint:all, treat all three commands as required validation targets.
7. After each modification batch, always run commands in this order:

- npm run lint:all
- npm run build
- npm run test
- Only proceed if all three pass, or report precisely what still fails.

## Workflow

1. Reproduce with all required commands:

- npm run lint:all
- npm run build
- npm run test

2. Identify failing symbols and map renamed generated types/fields in handwritten files.
3. Apply minimal patches in non-generated files only.
4. After each modification batch, rerun all commands in order:

- npm run lint:all
- npm run build
- npm run test

5. Report results and remaining failures, if any.

## Response Contract

- Explicitly mention that only non-generated files were changed.
- List changed files.
- If blocked by generated code, explain the blocker and propose regeneration path.

## Project Hint

In this repository, generated code is typically under `src/api/` and `src/model/`.
Handwritten integration points are under `src/core/` and `tests/`.
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,32 +83,39 @@ npm run spec:full
```

## Publishing

To generate a new version of the Upsun SDK Node and automatically publish it on https://npmjs.org

1. update your local

```bash
git fetch
git checkout main
git pull
```

2. check existing tags on https://github.com/upsun/upsun-sdk-node/tags
3. Update `package.json` version to the new release version (highest version + 1)
4. update `package-lock.json` using:
4. update `package-lock.json` using:

```bash
npm install
git add package.json package-lock.json
git commit -m "bump release version to v<x.y.z>"
git push
```

5. create a new tag from your local

```bash
git tag v<x.y.z>
git push --tag
```

6. Go on release page: https://github.com/upsun/upsun-sdk-node/releases
7. create a new release based on the previously created tag (Do not forget to autogenerate description in the form)
8. check publishing action status: https://github.com/upsun/upsun-sdk-node/actions
9. check new release version on https://www.npmjs.com/package/upsun-sdk-node
8. check publishing action status: https://github.com/upsun/upsun-sdk-node/actions
9. check new release version on https://www.npmjs.com/package/upsun-sdk-node

## Contributing

Expand Down
50,842 changes: 26,045 additions & 24,797 deletions schema/openapispec-upsun.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/core/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
CreateOrgSubscriptionRequest,
CreateProjectInviteRequest,
EnvironmentVariableCreateInput,
IntegrationCreateInput,
IntegrationCreateCreateInput,
ProjectVariableCreateInput,
} from '../model/index.js';

Expand All @@ -40,7 +40,7 @@ export type FilterListUsageRecords = Omit<ListOrgUsageRecordsRequest, 'organizat
export type FilterListOrgs = Omit<ListOrgsRequest, never>;

// used in ProjectTasks
export type IntegrationCreateData = Omit<IntegrationCreateInput, 'type'>;
export type IntegrationCreateData = Omit<IntegrationCreateCreateInput, 'type'>;
export type ProjectCreateRequest = Omit<CreateOrgSubscriptionRequest, 'projectRegion'>;
export type FilterListOrgProjects = Omit<ListOrgProjectsRequest, 'organizationId'>;

Expand Down
8 changes: 4 additions & 4 deletions src/core/tasks/environments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ import {
EnvironmentVariable,
FilesInner,
HttpAccessPermissions2,
Resources3InitEnum,
Resources4InitEnum,
Resources5InitEnum,
Resources6InitEnum,
Resources7InitEnum,
Route,
RouteCollection,
ServiceRelationshipsValue,
Expand Down Expand Up @@ -87,7 +87,7 @@ export class EnvironmentsTask extends TaskBase {
name: string,
cloneParent: boolean = true,
type: EnvironmentBranchInputTypeEnum = EnvironmentBranchInputTypeEnum.DEVELOPMENT,
init: Resources3InitEnum = Resources3InitEnum.PARENT,
init: Resources5InitEnum = Resources5InitEnum.PARENT,
): Promise<AcceptedResponse> {
TaskBase.checkProjectId(projectId);
TaskBase.checkEnvironmentId(environmentId);
Expand Down Expand Up @@ -226,7 +226,7 @@ export class EnvironmentsTask extends TaskBase {
repository: string,
files: FilesInner[],
config?: string,
init: Resources4InitEnum = Resources4InitEnum.DEFAULT,
init: Resources6InitEnum = Resources6InitEnum.DEFAULT,
): Promise<AcceptedResponse> {
TaskBase.checkProjectId(projectId);
TaskBase.checkEnvironmentId(environmentId);
Expand Down Expand Up @@ -291,7 +291,7 @@ export class EnvironmentsTask extends TaskBase {
async merge(
projectId: string,
environmentId: string,
init: Resources5InitEnum = Resources5InitEnum.DEFAULT,
init: Resources7InitEnum = Resources7InitEnum.DEFAULT,
): Promise<AcceptedResponse> {
TaskBase.checkProjectId(projectId);
TaskBase.checkEnvironmentId(environmentId);
Expand Down
2 changes: 1 addition & 1 deletion src/core/tasks/integrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class IntegrationsTask extends TaskBase {

return await this.thirdPartyIntegrationsApi.createProjectsIntegrations({
projectId,
integrationCreateInput: { type, ...params },
integrationCreateCreateInput: { type, ...params },
});
}

Expand Down
11 changes: 9 additions & 2 deletions src/core/tasks/mounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ import { UpsunClient } from '../../upsun.js';
import { DeploymentResourceGroup } from '../model.js';
import { TaskBase } from './task_base.js';

type DeploymentEntry = {
id?: string;
name?: string;
mounts?: Record<string, MountsValue>;
};

export class MountsTask extends TaskBase {
constructor(protected readonly client: UpsunClient) {
super(client);
Expand Down Expand Up @@ -38,11 +44,12 @@ export class MountsTask extends TaskBase {
for (const resourceType of resourceTypes) {
const group = currentDeployment[resourceType] ?? {};
for (const app of Object.values(group)) {
const appName = (app as any).name ?? (app as any).id;
const appEntry = app as DeploymentEntry;
const appName = appEntry.name ?? appEntry.id;
if (!appName) {
continue;
}
result[appName] = (app as any).mounts ?? {};
result[appName] = appEntry.mounts ?? {};
}
}

Expand Down
11 changes: 11 additions & 0 deletions tests/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"rootDir": "..",
"noEmit": true,
"isolatedModules": true,
"types": ["jest", "node"]
},
"include": ["./**/*.ts"],
"exclude": []
}
72 changes: 40 additions & 32 deletions tests/unit/tasks/environments.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ import {
AddressGrantsInnerPermissionEnum,
EnvironmentPatchTypeEnum,
EnvironmentBranchInputTypeEnum,
Resources3InitEnum,
Resources4InitEnum,
Resources5InitEnum,
Resources6InitEnum,
Resources7InitEnum,
} from '../../../src/model/index.js';
import { afterEach, beforeEach, describe, expect, it, jest } from '@jest/globals';

type AsyncMock = jest.Mock<(...args: any[]) => Promise<any>>;

jest.mock('../../../src/upsun');
jest.mock('../../../src/api/index.js');
Expand All @@ -22,34 +26,34 @@ describe('EnvironmentsTask', () => {
let environmentTask: EnvironmentsTask;
let mockClient: jest.Mocked<UpsunClient>;
let mockVariables: {
createEnvironmentVariable: jest.Mock;
deleteEnvironmentVariable: jest.Mock;
getEnvironmentVariable: jest.Mock;
listEnvironmentVariables: jest.Mock;
updateEnvironmentVariable: jest.Mock;
createEnvironmentVariable: AsyncMock;
deleteEnvironmentVariable: AsyncMock;
getEnvironmentVariable: AsyncMock;
listEnvironmentVariables: AsyncMock;
updateEnvironmentVariable: AsyncMock;
};
let mockRoutes: {
get: jest.Mock;
list: jest.Mock;
get: AsyncMock;
list: AsyncMock;
};
let mockActivities: {
cancel: jest.Mock;
get: jest.Mock;
list: jest.Mock;
cancel: AsyncMock;
get: AsyncMock;
list: AsyncMock;
};
let mockBackups: {
create: jest.Mock;
list: jest.Mock;
delete: jest.Mock;
get: jest.Mock;
restore: jest.Mock;
create: AsyncMock;
list: AsyncMock;
delete: AsyncMock;
get: AsyncMock;
restore: AsyncMock;
};
let mockDomains: {
add: jest.Mock;
delete: jest.Mock;
get: jest.Mock;
list: jest.Mock;
update: jest.Mock;
add: AsyncMock;
delete: AsyncMock;
get: AsyncMock;
list: AsyncMock;
update: AsyncMock;
};
let mockEnvironmentApi: jest.Mocked<EnvironmentApi>;
let mockEnvironmentTypeApi: jest.Mocked<EnvironmentTypeApi>;
Expand Down Expand Up @@ -168,13 +172,17 @@ describe('EnvironmentsTask', () => {
const mockResponse = { status: 'ok' } as any;
mockEnvironmentApi.activateEnvironment.mockResolvedValue(mockResponse);

const result = await environmentTask.activate('project-123', 'main', 'INIT_VAL');
const result = await environmentTask.activate(
'project-123',
'main',
Resources4InitEnum.DEFAULT,
);
expect(result).toBe(mockResponse);
expect(mockEnvironmentApi.activateEnvironment).toHaveBeenCalledWith({
projectId: 'project-123',
environmentId: 'main',
environmentActivateInput: {
resources: { init: 'INIT_VAL' },
resources: { init: Resources4InitEnum.DEFAULT },
},
});
});
Expand Down Expand Up @@ -205,7 +213,7 @@ describe('EnvironmentsTask', () => {
'my-env',
true,
EnvironmentBranchInputTypeEnum.DEVELOPMENT,
Resources3InitEnum.PARENT,
Resources5InitEnum.PARENT,
);
expect(result).toBe(mockResponse);
expect(mockEnvironmentApi.branchEnvironment).toHaveBeenCalledWith({
Expand All @@ -216,7 +224,7 @@ describe('EnvironmentsTask', () => {
name: 'my-env',
cloneParent: true,
type: EnvironmentBranchInputTypeEnum.DEVELOPMENT,
resources: { init: Resources3InitEnum.PARENT },
resources: { init: Resources5InitEnum.PARENT },
},
});
});
Expand Down Expand Up @@ -250,7 +258,7 @@ describe('EnvironmentsTask', () => {
'repo',
files,
'configVal',
Resources4InitEnum.DEFAULT,
Resources6InitEnum.DEFAULT,
);
expect(result).toBe(mockResponse);
expect(mockEnvironmentApi.initializeEnvironment).toHaveBeenCalledWith({
Expand All @@ -260,7 +268,7 @@ describe('EnvironmentsTask', () => {
profile: 'profile',
repository: 'repo',
config: 'configVal',
resources: { init: Resources4InitEnum.DEFAULT },
resources: { init: Resources6InitEnum.DEFAULT },
files: files,
},
});
Expand Down Expand Up @@ -296,7 +304,7 @@ describe('EnvironmentsTask', () => {
expect(mockEnvironmentApi.initializeEnvironment).toHaveBeenCalledWith(
expect.objectContaining({
environmentInitializeInput: expect.objectContaining({
resources: { init: Resources4InitEnum.DEFAULT },
resources: { init: Resources6InitEnum.DEFAULT },
}),
}),
);
Expand Down Expand Up @@ -409,12 +417,12 @@ describe('EnvironmentsTask', () => {
describe('merge', () => {
it('should merge an environment', async () => {
mockEnvironmentApi.mergeEnvironment.mockResolvedValue({} as any);
await environmentTask.merge('project-123', 'main', Resources5InitEnum.CHILD);
await environmentTask.merge('project-123', 'main', Resources7InitEnum.CHILD);
expect(mockEnvironmentApi.mergeEnvironment).toHaveBeenCalledWith({
projectId: 'project-123',
environmentId: 'main',
environmentMergeInput: {
resources: { init: Resources5InitEnum.CHILD },
resources: { init: Resources7InitEnum.CHILD },
},
});
});
Expand All @@ -425,7 +433,7 @@ describe('EnvironmentsTask', () => {
expect(mockEnvironmentApi.mergeEnvironment).toHaveBeenCalledWith(
expect.objectContaining({
environmentMergeInput: expect.objectContaining({
resources: { init: Resources5InitEnum.DEFAULT },
resources: { init: Resources7InitEnum.DEFAULT },
}),
}),
);
Expand Down Expand Up @@ -839,7 +847,7 @@ describe('EnvironmentsTask', () => {
it('should return relationships for an app', async () => {
const relationships = { db: { host: 'db', port: 5432 } } as any;
mockClient.applications = {
configGet: jest.fn().mockResolvedValue({ relationships }),
configGet: jest.fn<() => Promise<any>>().mockResolvedValue({ relationships }),
} as any;

const result = await environmentTask.relationships('project-123', 'main', 'app-1');
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/tasks/integrations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('IntegrationsTask', () => {
expect(result).toBeDefined();
expect(mockApi.createProjectsIntegrations).toHaveBeenCalledWith({
projectId: 'proj-1',
integrationCreateInput: { type: 'github', token: 'tok' },
integrationCreateCreateInput: { type: 'github', token: 'tok' },
});
});

Expand Down