@cargo-ai/worker-sdk 1.0.1

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 (38) hide show
  1. package/README.md +90 -0
  2. package/build/src/createWorker.d.ts +51 -0
  3. package/build/src/createWorker.d.ts.map +1 -0
  4. package/build/src/createWorker.js +44 -0
  5. package/build/src/customIntegration.d.ts +97 -0
  6. package/build/src/customIntegration.d.ts.map +1 -0
  7. package/build/src/customIntegration.js +212 -0
  8. package/build/src/index.d.ts +9 -0
  9. package/build/src/index.d.ts.map +1 -0
  10. package/build/src/index.js +4 -0
  11. package/build/src/types.d.ts +15 -0
  12. package/build/src/types.d.ts.map +1 -0
  13. package/build/src/types.js +1 -0
  14. package/build/tsconfig.tsbuildinfo +1 -0
  15. package/package.json +47 -0
  16. package/templates/blank/README.md +112 -0
  17. package/templates/blank/manifest.json +3 -0
  18. package/templates/blank/package.json +20 -0
  19. package/templates/blank/scripts/copy-runtime-files.mjs +25 -0
  20. package/templates/blank/src/index.ts +46 -0
  21. package/templates/blank/tsconfig.json +24 -0
  22. package/templates/custom-integration/.env.example +5 -0
  23. package/templates/custom-integration/README.md +136 -0
  24. package/templates/custom-integration/manifest.json +3 -0
  25. package/templates/custom-integration/package.json +21 -0
  26. package/templates/custom-integration/scripts/copy-runtime-files.mjs +25 -0
  27. package/templates/custom-integration/src/actions/createRecord.ts +34 -0
  28. package/templates/custom-integration/src/actions/index.ts +20 -0
  29. package/templates/custom-integration/src/authenticate.ts +27 -0
  30. package/templates/custom-integration/src/autocompletes/index.ts +13 -0
  31. package/templates/custom-integration/src/completeOauth.ts +10 -0
  32. package/templates/custom-integration/src/connectorConfig.ts +16 -0
  33. package/templates/custom-integration/src/dynamicSchemas/index.ts +13 -0
  34. package/templates/custom-integration/src/extractors/index.ts +18 -0
  35. package/templates/custom-integration/src/extractors/listRecords.ts +51 -0
  36. package/templates/custom-integration/src/index.ts +44 -0
  37. package/templates/custom-integration/src/listUsers.ts +11 -0
  38. package/templates/custom-integration/tsconfig.json +24 -0
@@ -0,0 +1,44 @@
1
+ import { createCustomIntegration } from "@cargo-ai/worker-sdk";
2
+
3
+ import { actions } from "./actions/index.js";
4
+ import { authenticate } from "./authenticate.js";
5
+ import { autocompletes } from "./autocompletes/index.js";
6
+ import { completeOauth } from "./completeOauth.js";
7
+ import { zodConnectorConfig } from "./connectorConfig.js";
8
+ import { dynamicSchemas } from "./dynamicSchemas/index.js";
9
+ import { extractors } from "./extractors/index.js";
10
+ import { listUsers } from "./listUsers.js";
11
+
12
+ const ICON =
13
+ '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="9"/></svg>';
14
+
15
+ const { app } = createCustomIntegration({
16
+ info: {
17
+ name: "__APP_NAME__",
18
+ description: "Custom integration backed by a Cargo worker.",
19
+ icon: ICON,
20
+ color: "#6366F1",
21
+ url: "https://example.com",
22
+ },
23
+ connector: {
24
+ config: {
25
+ schema: zodConnectorConfig,
26
+ uiSchema: {
27
+ apiKey: { "ui:widget": "password" },
28
+ },
29
+ },
30
+ rateLimit: {
31
+ unit: "minute",
32
+ max: 60,
33
+ },
34
+ },
35
+ authenticate,
36
+ listUsers,
37
+ completeOauth,
38
+ actions,
39
+ extractors,
40
+ autocompletes,
41
+ dynamicSchemas,
42
+ });
43
+
44
+ export default app;
@@ -0,0 +1,11 @@
1
+ import type { ConnectionTypes } from "@cargo-ai/types";
2
+
3
+ import type { ConnectorConfig } from "./connectorConfig.js";
4
+
5
+ export const listUsers = async (
6
+ _payload: ConnectionTypes.IntegrationListUsersPayload<ConnectorConfig>,
7
+ ): Promise<ConnectionTypes.IntegrationUserData[]> => {
8
+ // TODO: call the third-party API and map users into:
9
+ // [{ id, email, firstName?, lastName?, profileImage? }, ...]
10
+ return [];
11
+ };
@@ -0,0 +1,24 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "NodeNext",
5
+ "moduleResolution": "nodenext",
6
+ "lib": ["ES2022", "DOM", "DOM.Iterable"],
7
+ "rootDir": "./src",
8
+ "outDir": "./dist",
9
+ "strict": true,
10
+ "noImplicitAny": true,
11
+ "noUnusedLocals": true,
12
+ "noUnusedParameters": true,
13
+ "noFallthroughCasesInSwitch": true,
14
+ "noImplicitReturns": true,
15
+ "esModuleInterop": true,
16
+ "skipLibCheck": true,
17
+ "forceConsistentCasingInFileNames": true,
18
+ "resolveJsonModule": true,
19
+ "declaration": false,
20
+ "sourceMap": false,
21
+ "noEmitOnError": true
22
+ },
23
+ "include": ["src/**/*.ts"]
24
+ }