-
Notifications
You must be signed in to change notification settings - Fork 0
feat!: sync SDK with OpenAPI spec, remove stale resources, v3.0.0 #170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| 'scope3': major | ||
| --- | ||
|
|
||
| Sync SDK with current OpenAPI specification. Removes stale storefront-only and deprecated resources (agents, billing/storefront, inventory-sources, notifications, readiness, bundles, signals, sales-agents, conversion-events, creative-sets). Adds all missing buyer endpoints (discovery, accounts, planning-briefs, moderation, storefronts, audit-logs, notification-preferences). Replaces typed campaign creation methods with generic create/update/delete. Fixes schema generation regex escaping bug. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,158 +1,3 @@ | ||
| import { Command } from 'commander'; | ||
| import { storefrontCommand } from '../../../cli/commands/storefront'; | ||
| import * as utils from '../../../cli/utils'; | ||
| import * as format from '../../../cli/format'; | ||
|
|
||
| jest.mock('../../../cli/utils'); | ||
| jest.mock('../../../cli/format'); | ||
|
|
||
| const mockCreateClient = utils.createClient as jest.MockedFunction<typeof utils.createClient>; | ||
| const mockFormatOutput = format.formatOutput as jest.MockedFunction<typeof format.formatOutput>; | ||
| const mockPrintError = format.printError as jest.MockedFunction<typeof format.printError>; | ||
| const mockPrintSuccess = format.printSuccess as jest.MockedFunction<typeof format.printSuccess>; | ||
|
|
||
| describe('storefront command', () => { | ||
| let program: Command; | ||
| let mockClient: { | ||
| storefront: { | ||
| get: jest.Mock; | ||
| create: jest.Mock; | ||
| update: jest.Mock; | ||
| delete: jest.Mock; | ||
| }; | ||
| agents: { | ||
| list: jest.Mock; | ||
| get: jest.Mock; | ||
| }; | ||
| }; | ||
| const originalExit = process.exit; | ||
|
|
||
| beforeEach(() => { | ||
| mockClient = { | ||
| storefront: { | ||
| get: jest.fn(), | ||
| create: jest.fn(), | ||
| update: jest.fn(), | ||
| delete: jest.fn(), | ||
| }, | ||
| agents: { | ||
| list: jest.fn(), | ||
| get: jest.fn(), | ||
| }, | ||
| }; | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| mockCreateClient.mockReturnValue(mockClient as any); | ||
| process.exit = jest.fn() as never; | ||
|
|
||
| program = new Command(); | ||
| program.option('--api-key <key>', 'API key'); | ||
| program.option('--format <format>', 'Output format', 'table'); | ||
| program.option('--persona <persona>', 'Persona', 'storefront'); | ||
| program.addCommand(storefrontCommand); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| jest.restoreAllMocks(); | ||
| process.exit = originalExit; | ||
| }); | ||
|
|
||
| describe('get', () => { | ||
| it('should call client.storefront.get', async () => { | ||
| mockClient.storefront.get.mockResolvedValue({ | ||
| data: { platformId: 'plat-1', name: 'Test' }, | ||
| }); | ||
|
|
||
| await program.parseAsync(['node', 'test', 'storefront', 'get', '--api-key', 'sk-test']); | ||
|
|
||
| expect(mockClient.storefront.get).toHaveBeenCalled(); | ||
| expect(mockFormatOutput).toHaveBeenCalled(); | ||
| }); | ||
| }); | ||
|
|
||
| describe('create', () => { | ||
| it('should call client.storefront.create with required args', async () => { | ||
| mockClient.storefront.create.mockResolvedValue({ | ||
| data: { platformId: 'plat-1', name: 'My Store' }, | ||
| }); | ||
|
|
||
| await program.parseAsync([ | ||
| 'node', | ||
| 'test', | ||
| 'storefront', | ||
| 'create', | ||
| '--api-key', | ||
| 'sk-test', | ||
| '--platform-id', | ||
| 'plat-1', | ||
| '--name', | ||
| 'My Store', | ||
| ]); | ||
|
|
||
| expect(mockClient.storefront.create).toHaveBeenCalledWith( | ||
| expect.objectContaining({ | ||
| platformId: 'plat-1', | ||
| name: 'My Store', | ||
| }) | ||
| ); | ||
| expect(mockPrintSuccess).toHaveBeenCalled(); | ||
| }); | ||
| }); | ||
|
|
||
| describe('delete', () => { | ||
| it('should call client.storefront.delete', async () => { | ||
| mockClient.storefront.delete.mockResolvedValue(undefined); | ||
|
|
||
| await program.parseAsync(['node', 'test', 'storefront', 'delete', '--api-key', 'sk-test']); | ||
|
|
||
| expect(mockClient.storefront.delete).toHaveBeenCalled(); | ||
| expect(mockPrintSuccess).toHaveBeenCalled(); | ||
| }); | ||
| }); | ||
|
|
||
| describe('error handling', () => { | ||
| it('should print error and exit on failure', async () => { | ||
| mockClient.storefront.get.mockRejectedValue(new Error('Unauthorized')); | ||
|
|
||
| await program.parseAsync(['node', 'test', 'storefront', 'get', '--api-key', 'sk-test']); | ||
|
|
||
| expect(mockPrintError).toHaveBeenCalledWith('Unauthorized'); | ||
| expect(process.exit).toHaveBeenCalledWith(1); | ||
| }); | ||
| }); | ||
|
|
||
| describe('agents subcommand', () => { | ||
| it('should call client.agents.list', async () => { | ||
| mockClient.agents.list.mockResolvedValue({ data: [] }); | ||
|
|
||
| await program.parseAsync([ | ||
| 'node', | ||
| 'test', | ||
| 'storefront', | ||
| 'agents', | ||
| 'list', | ||
| '--api-key', | ||
| 'sk-test', | ||
| ]); | ||
|
|
||
| expect(mockClient.agents.list).toHaveBeenCalled(); | ||
| expect(mockFormatOutput).toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it('should call client.agents.get with agentId', async () => { | ||
| mockClient.agents.get.mockResolvedValue({ data: { id: 'agent-1' } }); | ||
|
|
||
| await program.parseAsync([ | ||
| 'node', | ||
| 'test', | ||
| 'storefront', | ||
| 'agents', | ||
| 'get', | ||
| 'agent-1', | ||
| '--api-key', | ||
| 'sk-test', | ||
| ]); | ||
|
|
||
| expect(mockClient.agents.get).toHaveBeenCalledWith('agent-1'); | ||
| }); | ||
| }); | ||
| describe('removed', () => { | ||
| it.todo('resource removed in v3'); | ||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the resource is gone, just delete the test file - the
describe('removed')placeholder is noise. also'resource removed in v3'is a temporal reference in code (same issue with the otherit.todostubs across the removed test files)