@offsida/sdk 0.1.0
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.
- package/LICENSE +21 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +5 -0
- package/dist/zod.d.ts +50 -0
- package/dist/zod.js +34 -0
- package/package.json +47 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Offsida
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// The authoring entry: the Zod-inferring `define*` helpers plus a re-export of the
|
|
2
|
+
// contract types, so an author needs a single import (`@offsida/sdk`). Prefer raw
|
|
3
|
+
// JSON Schema over Zod? Import the types from here (or `@offsida/types`) and write
|
|
4
|
+
// `... satisfies IntegrationPackage` by hand.
|
|
5
|
+
export * from './zod.js';
|
package/dist/zod.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { z, type ZodType } from 'zod';
|
|
2
|
+
import type { ActionCtx, AuthDescriptor, ConfigFieldDefinition, OAuthDescriptor, IntegrationPackage, JsonSchema, TriggerDefinition } from '@offsida/types';
|
|
3
|
+
type SchemaInput = ZodType | JsonSchema;
|
|
4
|
+
export type ZodAction<I = unknown> = {
|
|
5
|
+
title?: string;
|
|
6
|
+
requires?: string[];
|
|
7
|
+
inputSchema?: SchemaInput;
|
|
8
|
+
outputSchema?: SchemaInput;
|
|
9
|
+
run(input: I, ctx: ActionCtx): unknown | Promise<unknown>;
|
|
10
|
+
};
|
|
11
|
+
export type ZodConnectionDefinition = {
|
|
12
|
+
name: string;
|
|
13
|
+
title?: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
secretsSchema: SchemaInput;
|
|
16
|
+
auth?: AuthDescriptor;
|
|
17
|
+
oauth?: OAuthDescriptor;
|
|
18
|
+
test?(creds: unknown, ctx: ActionCtx): unknown | Promise<unknown>;
|
|
19
|
+
authorize?(ctx: {
|
|
20
|
+
config: unknown;
|
|
21
|
+
input?: unknown;
|
|
22
|
+
}): unknown | Promise<unknown>;
|
|
23
|
+
exchange?(ctx: {
|
|
24
|
+
config: unknown;
|
|
25
|
+
clientSecret?: string;
|
|
26
|
+
input?: unknown;
|
|
27
|
+
}, args: unknown): unknown | Promise<unknown>;
|
|
28
|
+
refresh?(ctx: {
|
|
29
|
+
config: unknown;
|
|
30
|
+
clientSecret?: string;
|
|
31
|
+
input?: unknown;
|
|
32
|
+
}, args: unknown): unknown | Promise<unknown>;
|
|
33
|
+
};
|
|
34
|
+
export type ZodIntegrationPackage = {
|
|
35
|
+
connections?: ZodConnectionDefinition[];
|
|
36
|
+
actions?: Record<string, ZodAction>;
|
|
37
|
+
triggers?: TriggerDefinition[];
|
|
38
|
+
config?: ConfigFieldDefinition[];
|
|
39
|
+
};
|
|
40
|
+
export declare function definePackage(pkg: ZodIntegrationPackage): IntegrationPackage;
|
|
41
|
+
export declare function defineAction<S extends ZodType>(a: {
|
|
42
|
+
title?: string;
|
|
43
|
+
requires?: string[];
|
|
44
|
+
inputSchema?: S;
|
|
45
|
+
outputSchema?: SchemaInput;
|
|
46
|
+
run(input: z.infer<S>, ctx: ActionCtx): unknown | Promise<unknown>;
|
|
47
|
+
}): ZodAction<z.infer<S>>;
|
|
48
|
+
export declare function defineConnection(c: ZodConnectionDefinition): ZodConnectionDefinition;
|
|
49
|
+
export declare function defineTrigger(t: TriggerDefinition): TriggerDefinition;
|
|
50
|
+
export {};
|
package/dist/zod.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
function isZod(v) {
|
|
3
|
+
return !!v && typeof v === 'object' && typeof v.safeParse === 'function';
|
|
4
|
+
}
|
|
5
|
+
function toJsonSchema(s) {
|
|
6
|
+
if (s === undefined)
|
|
7
|
+
return undefined;
|
|
8
|
+
if (isZod(s))
|
|
9
|
+
return z.toJSONSchema(s, { target: 'draft-2020-12' });
|
|
10
|
+
return s;
|
|
11
|
+
}
|
|
12
|
+
export function definePackage(pkg) {
|
|
13
|
+
return {
|
|
14
|
+
connections: pkg.connections?.map((c) => ({ ...c, secretsSchema: toJsonSchema(c.secretsSchema) })),
|
|
15
|
+
actions: pkg.actions
|
|
16
|
+
? Object.fromEntries(Object.entries(pkg.actions).map(([name, a]) => [
|
|
17
|
+
name,
|
|
18
|
+
{ ...a, inputSchema: toJsonSchema(a.inputSchema), outputSchema: toJsonSchema(a.outputSchema) },
|
|
19
|
+
]))
|
|
20
|
+
: undefined,
|
|
21
|
+
triggers: pkg.triggers,
|
|
22
|
+
config: pkg.config,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
// Typed action helper — infers run()'s input type from a Zod inputSchema.
|
|
26
|
+
export function defineAction(a) {
|
|
27
|
+
return a;
|
|
28
|
+
}
|
|
29
|
+
export function defineConnection(c) {
|
|
30
|
+
return c;
|
|
31
|
+
}
|
|
32
|
+
export function defineTrigger(t) {
|
|
33
|
+
return t;
|
|
34
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@offsida/sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"sideEffects": false,
|
|
6
|
+
"description": "Authoring helpers for Offsida integration packages — define connections, actions, and triggers with Zod schemas.",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/mark-ironbarklabs/offsida.web.git",
|
|
11
|
+
"directory": "lib/offsida/sdk"
|
|
12
|
+
},
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"default": "./dist/index.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"main": "./dist/index.js",
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=20"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@offsida/types": "0.1.0"
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"zod": "^4.4.3"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@types/node": "^25.9.3",
|
|
38
|
+
"typescript": "^5.9.3",
|
|
39
|
+
"vitest": "^3.2.6",
|
|
40
|
+
"zod": "^4.4.3"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "tsc",
|
|
44
|
+
"test": "vitest run",
|
|
45
|
+
"typecheck": "tsc --noEmit"
|
|
46
|
+
}
|
|
47
|
+
}
|