@apifuse/provider-sdk 2.2.0-beta.54 → 2.2.0-beta.55

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/cli/migrate-operation-declaration.d.ts +5 -1
  3. package/dist/cli/migrate-operation-declaration.js +645 -46
  4. package/package.json +1 -1
  5. package/src/cli/__tests__/fixtures/migrate-operation-declaration/discovery-ambiguous-a.ts.txt +3 -0
  6. package/src/cli/__tests__/fixtures/migrate-operation-declaration/discovery-ambiguous-b.ts.txt +3 -0
  7. package/src/cli/__tests__/fixtures/migrate-operation-declaration/discovery-ambiguous-barrel.ts.txt +2 -0
  8. package/src/cli/__tests__/fixtures/migrate-operation-declaration/discovery-ambiguous-index.ts.txt +3 -0
  9. package/src/cli/__tests__/fixtures/migrate-operation-declaration/discovery-computed.ts.txt +6 -0
  10. package/src/cli/__tests__/fixtures/migrate-operation-declaration/discovery-cycle-a.ts.txt +1 -0
  11. package/src/cli/__tests__/fixtures/migrate-operation-declaration/discovery-cycle-b.ts.txt +1 -0
  12. package/src/cli/__tests__/fixtures/migrate-operation-declaration/discovery-cycle-index.ts.txt +3 -0
  13. package/src/cli/__tests__/fixtures/migrate-operation-declaration/discovery-daiso-barrel.ts.txt +7 -0
  14. package/src/cli/__tests__/fixtures/migrate-operation-declaration/discovery-daiso-catalog.ts.txt +19 -0
  15. package/src/cli/__tests__/fixtures/migrate-operation-declaration/discovery-daiso-docs.ts.txt +6 -0
  16. package/src/cli/__tests__/fixtures/migrate-operation-declaration/discovery-daiso-index.ts.txt +3 -0
  17. package/src/cli/__tests__/fixtures/migrate-operation-declaration/discovery-daiso-stores.ts.txt +8 -0
  18. package/src/cli/__tests__/fixtures/migrate-operation-declaration/discovery-indirect-config.ts.txt +5 -0
  19. package/src/cli/__tests__/fixtures/migrate-operation-declaration/discovery-nonstatic.ts.txt +4 -0
  20. package/src/cli/__tests__/fixtures/migrate-operation-declaration/discovery-package-index.ts.txt +3 -0
  21. package/src/cli/__tests__/fixtures/migrate-operation-declaration/discovery-reexport-index.ts.txt +3 -0
  22. package/src/cli/__tests__/fixtures/migrate-operation-declaration/discovery-reexport-leaf.ts.txt +10 -0
  23. package/src/cli/__tests__/fixtures/migrate-operation-declaration/discovery-reexport-one.ts.txt +1 -0
  24. package/src/cli/__tests__/fixtures/migrate-operation-declaration/discovery-reexport-two.ts.txt +1 -0
  25. package/src/cli/__tests__/fixtures/migrate-operation-declaration/discovery-star-package-barrel.ts.txt +2 -0
  26. package/src/cli/__tests__/fixtures/migrate-operation-declaration/discovery-star-package-index.ts.txt +3 -0
  27. package/src/cli/__tests__/fixtures/migrate-operation-declaration/discovery-star-package-leaf.ts.txt +3 -0
  28. package/src/cli/__tests__/fixtures/migrate-operation-declaration/factory-duplicate-provider.ts.txt +11 -0
  29. package/src/cli/__tests__/fixtures/migrate-operation-declaration/factory-id-unresolved.ts.txt +7 -0
  30. package/src/cli/__tests__/fixtures/migrate-operation-declaration/factory-one-to-many.ts.txt +18 -0
  31. package/src/cli/__tests__/fixtures/migrate-operation-declaration/factory-one-to-one.ts.txt +13 -0
  32. package/src/cli/migrate-operation-declaration.ts +844 -49
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.2.0-beta.54",
2
+ "version": "2.2.0-beta.55",
3
3
  "name": "@apifuse/provider-sdk",
4
4
  "private": false,
5
5
  "type": "module",
@@ -0,0 +1,3 @@
1
+ export const registry = {
2
+ first: { annotations: { readOnly: true }, input: InputSchema, output: OutputSchema, handler },
3
+ };
@@ -0,0 +1,3 @@
1
+ export const registry = {
2
+ second: { annotations: { readOnly: true }, input: InputSchema, output: OutputSchema, handler },
3
+ };
@@ -0,0 +1,2 @@
1
+ export * from "./ambiguous-a";
2
+ export * from "./ambiguous-b";
@@ -0,0 +1,3 @@
1
+ import { registry } from "./ambiguous-barrel";
2
+
3
+ export default buildProvider({ operations: registry });
@@ -0,0 +1,6 @@
1
+ const operationId = "ping";
2
+ const registry = {
3
+ [operationId]: { annotations: { readOnly: true }, input: InputSchema, output: OutputSchema, handler },
4
+ };
5
+
6
+ export default buildProvider({ operations: registry });
@@ -0,0 +1 @@
1
+ export { registry } from "./cycle-b";
@@ -0,0 +1 @@
1
+ export { registry } from "./cycle-a";
@@ -0,0 +1,3 @@
1
+ import { registry } from "./cycle-a";
2
+
3
+ export default buildProvider({ operations: registry });
@@ -0,0 +1,7 @@
1
+ import { catalogOperations } from "./catalog";
2
+ import { storeOperations } from "./stores";
3
+
4
+ export const daisoOperations = {
5
+ ...catalogOperations,
6
+ ...storeOperations,
7
+ };
@@ -0,0 +1,19 @@
1
+ import { OPERATION_DOCS } from "./docs";
2
+
3
+ export const catalogOperations = {
4
+ "browse-catalog": {
5
+ docs: { ...OPERATION_DOCS.catalog },
6
+ descriptionKey: "operations.browseCatalog.description",
7
+ annotations: { readOnly: true },
8
+ inputExamples: [{ scenario: "Browse the catalog", input: {} }],
9
+ input: InputSchema,
10
+ output: OutputSchema,
11
+ handler,
12
+ },
13
+ "search-products": {
14
+ annotations: { readOnly: true },
15
+ input: InputSchema,
16
+ output: OutputSchema,
17
+ handler,
18
+ },
19
+ };
@@ -0,0 +1,6 @@
1
+ export const OPERATION_DOCS = {
2
+ catalog: {
3
+ titleKey: "operations.groupedRead.title",
4
+ descriptionKey: "operations.groupedRead.description",
5
+ },
6
+ };
@@ -0,0 +1,3 @@
1
+ import { daisoOperations } from "./operations";
2
+
3
+ export default buildProvider({ operations: daisoOperations });
@@ -0,0 +1,8 @@
1
+ export const storeOperations = {
2
+ "search-stores": {
3
+ annotations: { readOnly: true },
4
+ input: InputSchema,
5
+ output: OutputSchema,
6
+ handler,
7
+ },
8
+ };
@@ -0,0 +1,5 @@
1
+ import { packageRegistry } from "provider-operation-package";
2
+
3
+ const config = { operations: packageRegistry };
4
+
5
+ export default buildProvider(config);
@@ -0,0 +1,4 @@
1
+ const first = { ping: pingOperation };
2
+ const second = { pong: pongOperation };
3
+
4
+ export default buildProvider({ operations: enabled ? first : second });
@@ -0,0 +1,3 @@
1
+ import { packageRegistry } from "provider-operation-package";
2
+
3
+ export default buildProvider({ operations: packageRegistry });
@@ -0,0 +1,3 @@
1
+ import { registry } from "./barrel-one.js";
2
+
3
+ export default buildProvider({ operations: registry });
@@ -0,0 +1,10 @@
1
+ const leafRegistry = {
2
+ ping: {
3
+ annotations: { readOnly: true },
4
+ input: InputSchema,
5
+ output: OutputSchema,
6
+ handler,
7
+ },
8
+ };
9
+
10
+ export const registry = leafRegistry;
@@ -0,0 +1 @@
1
+ export { registry } from "./barrel-two.js";
@@ -0,0 +1 @@
1
+ export { registry } from "./leaf";
@@ -0,0 +1,2 @@
1
+ export * from "provider-operation-package";
2
+ export * from "./star-leaf";
@@ -0,0 +1,3 @@
1
+ import { registry } from "./star-barrel";
2
+
3
+ export default buildProvider({ operations: registry });
@@ -0,0 +1,3 @@
1
+ export const registry = {
2
+ ping: { annotations: { readOnly: true }, input: InputSchema, output: OutputSchema, handler },
3
+ };
@@ -0,0 +1,11 @@
1
+ function makePingOperation() {
2
+ return defineOperation<ProviderContext>()({
3
+ annotations: { readOnly: true },
4
+ input: InputSchema,
5
+ output: OutputSchema,
6
+ handler,
7
+ });
8
+ }
9
+
10
+ export const first = buildProvider({ operations: { ping: makePingOperation() } });
11
+ export default buildProvider({ operations: { ping: makePingOperation() } });
@@ -0,0 +1,7 @@
1
+ defineOperation<ProviderContext>()({
2
+ annotations: { readOnly: true },
3
+ inputExamples: [{ scenario: "Anonymous", input: {} }],
4
+ input: InputSchema,
5
+ output: OutputSchema,
6
+ handler,
7
+ });
@@ -0,0 +1,18 @@
1
+ function makeSearchOperation(kind: string) {
2
+ return defineOperation<ProviderContext>()({
3
+ annotations: { readOnly: true },
4
+ inputExamples: [{ scenario: "Search items", input: { kind } }],
5
+ input: InputSchema,
6
+ output: OutputSchema,
7
+ handler,
8
+ });
9
+ }
10
+
11
+ export default buildProvider({
12
+ operations: {
13
+ "used-goods-search": makeSearchOperation("used"),
14
+ "realty-search-listings": makeSearchOperation("realty"),
15
+ "jobs-search": makeSearchOperation("jobs"),
16
+ "cars-search": makeSearchOperation("cars"),
17
+ },
18
+ });
@@ -0,0 +1,13 @@
1
+ function makeSearchOperation(kind: string) {
2
+ return defineOperation<ProviderContext>()({
3
+ annotations: { readOnly: true },
4
+ inputExamples: [{ scenario: "Search items", input: { kind } }],
5
+ input: InputSchema,
6
+ output: OutputSchema,
7
+ handler,
8
+ });
9
+ }
10
+
11
+ export default buildProvider({
12
+ operations: { "search-items": makeSearchOperation("items") },
13
+ });