@harnesys/sdk 0.0.0-stage → 1.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/README.md +80 -2
- package/dist/addon-context-factory.d.ts +6 -0
- package/dist/addon-context-factory.js +160 -0
- package/dist/addon-context.d.ts +346 -0
- package/dist/addon-context.js +0 -0
- package/dist/define-addon.d.ts +57 -0
- package/dist/define-addon.js +53 -0
- package/dist/families/config.d.ts +14 -0
- package/dist/families/config.js +16 -0
- package/dist/families/content.d.ts +28 -0
- package/dist/families/content.js +19 -0
- package/dist/families/field-spec.d.ts +100 -0
- package/dist/families/field-spec.js +85 -0
- package/dist/families/hook.d.ts +37 -0
- package/dist/families/hook.js +25 -0
- package/dist/families/job.d.ts +45 -0
- package/dist/families/job.js +26 -0
- package/dist/families/json-schema-value.d.ts +12 -0
- package/dist/families/json-schema-value.js +243 -0
- package/dist/families/json-schema.d.ts +36 -0
- package/dist/families/json-schema.js +101 -0
- package/dist/families/lsp.d.ts +18 -0
- package/dist/families/lsp.js +18 -0
- package/dist/families/mcp.d.ts +18 -0
- package/dist/families/mcp.js +18 -0
- package/dist/families/registry.d.ts +9 -0
- package/dist/families/registry.js +34 -0
- package/dist/families/route.d.ts +38 -0
- package/dist/families/route.js +37 -0
- package/dist/families/source-kind.d.ts +24 -0
- package/dist/families/source-kind.js +21 -0
- package/dist/families/tool-pack.d.ts +68 -0
- package/dist/families/tool-pack.js +57 -0
- package/dist/families/transport.d.ts +52 -0
- package/dist/families/transport.js +29 -0
- package/dist/families/trigger.d.ts +97 -0
- package/dist/families/trigger.js +46 -0
- package/dist/families/view.d.ts +255 -0
- package/dist/families/view.js +87 -0
- package/dist/families/viewer.d.ts +31 -0
- package/dist/families/viewer.js +26 -0
- package/dist/families/worker.d.ts +23 -0
- package/dist/families/worker.js +19 -0
- package/dist/host-client.d.ts +11 -0
- package/dist/host-client.js +30 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.js +36 -0
- package/dist/manifest/branding.d.ts +14 -0
- package/dist/manifest/branding.js +18 -0
- package/dist/manifest/connections.d.ts +21 -0
- package/dist/manifest/connections.js +10 -0
- package/dist/manifest/json-schema.d.ts +2 -0
- package/dist/manifest/json-schema.js +13 -0
- package/dist/manifest/l10n.d.ts +9 -0
- package/dist/manifest/l10n.js +28 -0
- package/dist/manifest/manifest.d.ts +112 -0
- package/dist/manifest/manifest.js +45 -0
- package/dist/manifest/validate.d.ts +14 -0
- package/dist/manifest/validate.js +144 -0
- package/dist/permissions/permissions.d.ts +31 -0
- package/dist/permissions/permissions.js +53 -0
- package/dist/process-entry.d.ts +26 -0
- package/dist/process-entry.js +146 -0
- package/dist/protocol/envelope.d.ts +115 -0
- package/dist/protocol/envelope.js +72 -0
- package/dist/protocol/error.d.ts +67 -0
- package/dist/protocol/error.js +61 -0
- package/dist/protocol/handshake.d.ts +55 -0
- package/dist/protocol/handshake.js +26 -0
- package/dist/protocol/map.d.ts +1090 -0
- package/dist/protocol/map.js +127 -0
- package/dist/protocol/meta.d.ts +31 -0
- package/dist/protocol/meta.js +14 -0
- package/dist/protocol/method-spec.d.ts +13 -0
- package/dist/protocol/method-spec.js +9 -0
- package/dist/protocol/org-service-methods.d.ts +135 -0
- package/dist/protocol/org-service-methods.js +106 -0
- package/dist/protocol/shared.d.ts +389 -0
- package/dist/protocol/shared.js +231 -0
- package/dist/protocol/source-methods.d.ts +218 -0
- package/dist/protocol/source-methods.js +18 -0
- package/dist/protocol/thread-service-methods.d.ts +50 -0
- package/dist/protocol/thread-service-methods.js +32 -0
- package/dist/runtime.d.ts +25 -0
- package/dist/runtime.js +229 -0
- package/dist/testing/fake-db.d.ts +15 -0
- package/dist/testing/fake-db.js +120 -0
- package/dist/testing/fake-files.d.ts +9 -0
- package/dist/testing/fake-files.js +87 -0
- package/dist/testing/fake-host.d.ts +115 -0
- package/dist/testing/fake-host.js +217 -0
- package/dist/testing/fake-services.d.ts +63 -0
- package/dist/testing/fake-services.js +277 -0
- package/dist/testing/fixtures.d.ts +5 -0
- package/dist/testing/fixtures.js +101 -0
- package/dist/testing/index.d.ts +4 -0
- package/dist/testing/index.js +2 -0
- package/package.json +66 -4
- package/src/addon-context-factory.ts +236 -0
- package/src/addon-context.ts +313 -0
- package/src/define-addon.ts +178 -0
- package/src/families/config.ts +24 -0
- package/src/families/content.ts +35 -0
- package/src/families/field-spec.ts +175 -0
- package/src/families/hook.ts +34 -0
- package/src/families/job.ts +41 -0
- package/src/families/json-schema-value.ts +322 -0
- package/src/families/json-schema.ts +167 -0
- package/src/families/lsp.ts +28 -0
- package/src/families/mcp.ts +28 -0
- package/src/families/registry.ts +44 -0
- package/src/families/route.ts +52 -0
- package/src/families/source-kind.ts +34 -0
- package/src/families/tool-pack.ts +92 -0
- package/src/families/transport.ts +52 -0
- package/src/families/trigger.ts +92 -0
- package/src/families/view.ts +144 -0
- package/src/families/viewer.ts +43 -0
- package/src/families/worker.ts +30 -0
- package/src/host-client.ts +52 -0
- package/src/index.ts +345 -0
- package/src/manifest/branding.ts +24 -0
- package/src/manifest/connections.ts +21 -0
- package/src/manifest/json-schema.ts +24 -0
- package/src/manifest/l10n.ts +39 -0
- package/src/manifest/manifest.ts +94 -0
- package/src/manifest/validate.ts +200 -0
- package/src/permissions/permissions.ts +79 -0
- package/src/process-entry.ts +205 -0
- package/src/protocol/envelope.ts +126 -0
- package/src/protocol/error.ts +81 -0
- package/src/protocol/handshake.ts +43 -0
- package/src/protocol/map.ts +339 -0
- package/src/protocol/meta.ts +26 -0
- package/src/protocol/method-spec.ts +40 -0
- package/src/protocol/org-service-methods.ts +148 -0
- package/src/protocol/shared.ts +345 -0
- package/src/protocol/source-methods.ts +61 -0
- package/src/protocol/thread-service-methods.ts +50 -0
- package/src/runtime.ts +332 -0
- package/src/testing/fake-db.ts +140 -0
- package/src/testing/fake-files.ts +114 -0
- package/src/testing/fake-host.ts +350 -0
- package/src/testing/fake-services.ts +345 -0
- package/src/testing/fixtures.ts +106 -0
- package/src/testing/index.ts +12 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { ResolvedAddonDefinition } from '../define-addon.ts';
|
|
2
|
+
import { defineAddon } from '../define-addon.ts';
|
|
3
|
+
import type { AddonManifest } from '../manifest/manifest.ts';
|
|
4
|
+
|
|
5
|
+
export function validManifest(): AddonManifest {
|
|
6
|
+
return {
|
|
7
|
+
id: 'harnesys.demo',
|
|
8
|
+
version: '1.0.0',
|
|
9
|
+
platform: 1,
|
|
10
|
+
title: 'Demo',
|
|
11
|
+
description: 'Demo addon',
|
|
12
|
+
runtime: { entry: './dist/index.js', profile: 'restricted' },
|
|
13
|
+
activation: 'lazy',
|
|
14
|
+
permissions: [
|
|
15
|
+
{ id: 'http.fetch', scope: { hosts: ['api.example.com'] }, reason: 'Calls the example API' },
|
|
16
|
+
],
|
|
17
|
+
connections: [
|
|
18
|
+
{
|
|
19
|
+
id: 'example',
|
|
20
|
+
label: 'Example connection',
|
|
21
|
+
accountKinds: ['example-account'],
|
|
22
|
+
cardinality: 'many',
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
contributions: [
|
|
26
|
+
{
|
|
27
|
+
id: 'pack',
|
|
28
|
+
family: 'tool-pack',
|
|
29
|
+
descriptor: {
|
|
30
|
+
name: 'example',
|
|
31
|
+
title: 'Example tools',
|
|
32
|
+
description: 'Tools for the demo',
|
|
33
|
+
connection: 'example',
|
|
34
|
+
tools: [
|
|
35
|
+
{
|
|
36
|
+
name: 'example.ping',
|
|
37
|
+
description: 'Ping',
|
|
38
|
+
inputSchema: { type: 'object' },
|
|
39
|
+
effect: 'read',
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
id: 'hook',
|
|
46
|
+
family: 'hook',
|
|
47
|
+
descriptor: { id: 'onThread', on: { event: 'thread.*' } },
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function toolPackManifest(tools: Array<Record<string, unknown>>): AddonManifest {
|
|
54
|
+
return {
|
|
55
|
+
...validManifest(),
|
|
56
|
+
contributions: [
|
|
57
|
+
{
|
|
58
|
+
id: 'pack',
|
|
59
|
+
family: 'tool-pack',
|
|
60
|
+
descriptor: {
|
|
61
|
+
name: 'example',
|
|
62
|
+
title: 'Example tools',
|
|
63
|
+
description: 'Tools for the demo',
|
|
64
|
+
tools,
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function demoDefinition(): ResolvedAddonDefinition {
|
|
72
|
+
return defineAddon({
|
|
73
|
+
tools: {
|
|
74
|
+
'example.ping': (input, ctx) => ({ pong: true, echo: input, org: ctx.meta.correlationId }),
|
|
75
|
+
},
|
|
76
|
+
routes: {
|
|
77
|
+
items: async () => ({ status: 200, body: { rows: [] } }),
|
|
78
|
+
},
|
|
79
|
+
triggers: {
|
|
80
|
+
'telegram.feed': {
|
|
81
|
+
start: async () => undefined,
|
|
82
|
+
stop: async () => undefined,
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
jobs: {
|
|
86
|
+
sync: async (_params, ctx) => {
|
|
87
|
+
await ctx.log.info('job ran');
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
hooks: {
|
|
91
|
+
onThread: async () => undefined,
|
|
92
|
+
},
|
|
93
|
+
sources: {
|
|
94
|
+
example: {
|
|
95
|
+
list: async () => ({ entries: [{ id: 'file-1', name: 'notes.txt', kind: 'file' }] }),
|
|
96
|
+
stat: async (params) => ({
|
|
97
|
+
entry: { id: params.fileId, name: 'notes.txt', kind: 'file' },
|
|
98
|
+
}),
|
|
99
|
+
download: async () => ({ data: '', eof: true }),
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
transport: {
|
|
103
|
+
typing: async () => undefined,
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type { FakeDb } from './fake-db.ts';
|
|
2
|
+
export { createFakeDb, guardSql, SqlAuthorizerError } from './fake-db.ts';
|
|
3
|
+
export type {
|
|
4
|
+
FakeAccount,
|
|
5
|
+
FakeGrant,
|
|
6
|
+
FakeHost,
|
|
7
|
+
FakeHostOptions,
|
|
8
|
+
FakeHttpHandler,
|
|
9
|
+
FakeHttpRequest,
|
|
10
|
+
FakeHttpResponse,
|
|
11
|
+
} from './fake-host.ts';
|
|
12
|
+
export { createFakeHost } from './fake-host.ts';
|