@minca/core 0.1.18 → 0.3.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.
- package/README.md +1 -1
- package/dist/identity/abilities.d.ts +0 -2
- package/dist/identity/abilities.d.ts.map +1 -1
- package/dist/identity/abilities.js +2 -2
- package/dist/identity/abilities.js.map +1 -1
- package/dist/identity/account-vault.d.ts +0 -2
- package/dist/identity/account-vault.d.ts.map +1 -1
- package/dist/identity/account-vault.js +1 -1
- package/dist/identity/account-vault.js.map +1 -1
- package/dist/identity/crypto-p256.d.ts +1 -1
- package/dist/identity/crypto-p256.d.ts.map +1 -1
- package/dist/identity/ucan.d.ts +2 -1
- package/dist/identity/ucan.d.ts.map +1 -1
- package/dist/identity/ucan.js +1 -1
- package/dist/identity/ucan.js.map +1 -1
- package/dist/inbox/inbox.d.ts +0 -21
- package/dist/inbox/inbox.d.ts.map +1 -1
- package/dist/inbox/inbox.js +4 -4
- package/dist/inbox/inbox.js.map +1 -1
- package/dist/inbox/index.d.ts +4 -5
- package/dist/inbox/index.d.ts.map +1 -1
- package/dist/inbox/index.js +2 -3
- package/dist/inbox/index.js.map +1 -1
- package/dist/inbox/names.d.ts +0 -4
- package/dist/inbox/names.d.ts.map +1 -1
- package/dist/inbox/names.js +2 -2
- package/dist/inbox/names.js.map +1 -1
- package/dist/index.d.ts +45 -71
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +34 -53
- package/dist/index.js.map +1 -1
- package/dist/network/mesh.d.ts.map +1 -1
- package/dist/network/mesh.js +10 -0
- package/dist/network/mesh.js.map +1 -1
- package/dist/network/rendezvous.d.ts +2 -0
- package/dist/network/rendezvous.d.ts.map +1 -1
- package/dist/network/rendezvous.js +5 -0
- package/dist/network/rendezvous.js.map +1 -1
- package/dist/network/rtc-transport.d.ts.map +1 -1
- package/dist/network/rtc-transport.js +8 -3
- package/dist/network/rtc-transport.js.map +1 -1
- package/dist/node/carrier.d.ts +1 -33
- package/dist/node/carrier.d.ts.map +1 -1
- package/dist/node/carrier.js +38 -68
- package/dist/node/carrier.js.map +1 -1
- package/dist/node/index.d.ts +7 -14
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +4 -8
- package/dist/node/index.js.map +1 -1
- package/dist/node/node-carriers.d.ts.map +1 -1
- package/dist/node/node-carriers.js +21 -52
- package/dist/node/node-carriers.js.map +1 -1
- package/dist/node/node-context.d.ts +0 -2
- package/dist/node/node-context.d.ts.map +1 -1
- package/dist/node/node-context.js.map +1 -1
- package/dist/node/node-hosting.d.ts.map +1 -1
- package/dist/node/node-hosting.js +13 -4
- package/dist/node/node-hosting.js.map +1 -1
- package/dist/node/node-records.js +1 -1
- package/dist/node/node-records.js.map +1 -1
- package/dist/node/node.d.ts.map +1 -1
- package/dist/node/node.js +134 -36
- package/dist/node/node.js.map +1 -1
- package/dist/node/space-checks.d.ts +3 -1
- package/dist/node/space-checks.d.ts.map +1 -1
- package/dist/node/space-checks.js +7 -3
- package/dist/node/space-checks.js.map +1 -1
- package/dist/node/space-holding.d.ts +5 -0
- package/dist/node/space-holding.d.ts.map +1 -1
- package/dist/node/space-holding.js +90 -5
- package/dist/node/space-holding.js.map +1 -1
- package/dist/node/space-lines.d.ts +3 -0
- package/dist/node/space-lines.d.ts.map +1 -1
- package/dist/node/space-lines.js +13 -1
- package/dist/node/space-lines.js.map +1 -1
- package/dist/node/space-membership.js +4 -4
- package/dist/node/space-membership.js.map +1 -1
- package/dist/node/space-peers.d.ts +5 -2
- package/dist/node/space-peers.d.ts.map +1 -1
- package/dist/node/space-peers.js +3 -2
- package/dist/node/space-peers.js.map +1 -1
- package/dist/node/space-runtime.d.ts +3 -1
- package/dist/node/space-runtime.d.ts.map +1 -1
- package/dist/node/space-runtime.js +29 -8
- package/dist/node/space-runtime.js.map +1 -1
- package/dist/node/space-standing.d.ts +1 -1
- package/dist/node/space-standing.d.ts.map +1 -1
- package/dist/node/space-standing.js +11 -4
- package/dist/node/space-standing.js.map +1 -1
- package/dist/node/space-writing.d.ts.map +1 -1
- package/dist/node/space-writing.js +9 -0
- package/dist/node/space-writing.js.map +1 -1
- package/dist/node/stores.d.ts +9 -1
- package/dist/node/stores.d.ts.map +1 -1
- package/dist/node/stores.js +4 -2
- package/dist/node/stores.js.map +1 -1
- package/dist/node/types.d.ts +16 -5
- package/dist/node/types.d.ts.map +1 -1
- package/dist/node/worker.d.ts +14 -6
- package/dist/node/worker.d.ts.map +1 -1
- package/dist/node/worker.js +59 -20
- package/dist/node/worker.js.map +1 -1
- package/dist/node/writer-keys.d.ts +2 -2
- package/dist/node/writer-keys.d.ts.map +1 -1
- package/dist/node/writer-keys.js +12 -14
- package/dist/node/writer-keys.js.map +1 -1
- package/dist/privacy/direct.d.ts +0 -7
- package/dist/privacy/direct.d.ts.map +1 -1
- package/dist/privacy/direct.js +2 -2
- package/dist/privacy/direct.js.map +1 -1
- package/dist/query/filter.d.ts +0 -2
- package/dist/query/filter.d.ts.map +1 -1
- package/dist/query/filter.js +1 -1
- package/dist/query/filter.js.map +1 -1
- package/dist/query/types.d.ts +2 -6
- package/dist/query/types.d.ts.map +1 -1
- package/dist/query/types.js.map +1 -1
- package/dist/records/key.d.ts +2 -0
- package/dist/records/key.d.ts.map +1 -1
- package/dist/records/key.js +4 -0
- package/dist/records/key.js.map +1 -1
- package/dist/records/links.js +1 -1
- package/dist/schemas/direct.d.ts +70 -0
- package/dist/schemas/direct.d.ts.map +1 -0
- package/dist/schemas/direct.js +39 -0
- package/dist/schemas/direct.js.map +1 -0
- package/dist/schemas/index.d.ts +10 -73
- package/dist/schemas/index.d.ts.map +1 -1
- package/dist/schemas/index.js +8 -66
- package/dist/schemas/index.js.map +1 -1
- package/dist/session/account-hint.d.ts +2 -2
- package/dist/session/account-hint.d.ts.map +1 -1
- package/dist/session/account-hint.js +3 -3
- package/dist/session/account-hint.js.map +1 -1
- package/dist/session/connect.d.ts +12 -5
- package/dist/session/connect.d.ts.map +1 -1
- package/dist/session/connect.js +25 -21
- package/dist/session/connect.js.map +1 -1
- package/dist/session/connection.d.ts +26 -2
- package/dist/session/connection.d.ts.map +1 -1
- package/dist/session/connection.js +151 -11
- package/dist/session/connection.js.map +1 -1
- package/dist/session/hosting.d.ts +1 -7
- package/dist/session/hosting.d.ts.map +1 -1
- package/dist/session/hosting.js +3 -3
- package/dist/session/hosting.js.map +1 -1
- package/dist/session/index.d.ts +9 -14
- package/dist/session/index.d.ts.map +1 -1
- package/dist/session/index.js +8 -11
- package/dist/session/index.js.map +1 -1
- package/dist/session/stay-signed-in.d.ts +0 -1
- package/dist/session/stay-signed-in.d.ts.map +1 -1
- package/dist/session/stay-signed-in.js +1 -1
- package/dist/session/stay-signed-in.js.map +1 -1
- package/dist/space/account-registry.d.ts +0 -3
- package/dist/space/account-registry.d.ts.map +1 -1
- package/dist/space/account-registry.js.map +1 -1
- package/dist/space/own-automations.d.ts +51 -95
- package/dist/space/own-automations.d.ts.map +1 -1
- package/dist/space/own-automations.js +100 -295
- package/dist/space/own-automations.js.map +1 -1
- package/dist/space/pass.d.ts +8 -3
- package/dist/space/pass.d.ts.map +1 -1
- package/dist/space/pass.js +4 -3
- package/dist/space/pass.js.map +1 -1
- package/dist/space/space-manager.d.ts +1 -3
- package/dist/space/space-manager.d.ts.map +1 -1
- package/dist/space/space-manager.js +5 -7
- package/dist/space/space-manager.js.map +1 -1
- package/dist/storage/body-cache.d.ts +26 -0
- package/dist/storage/body-cache.d.ts.map +1 -0
- package/dist/storage/body-cache.js +41 -0
- package/dist/storage/body-cache.js.map +1 -0
- package/dist/storage/encrypted-adapter.d.ts +0 -5
- package/dist/storage/encrypted-adapter.d.ts.map +1 -1
- package/dist/storage/encrypted-adapter.js +1 -1
- package/dist/storage/encrypted-adapter.js.map +1 -1
- package/dist/storage/folder-adapter.d.ts +8 -2
- package/dist/storage/folder-adapter.d.ts.map +1 -1
- package/dist/storage/folder-adapter.js +43 -26
- package/dist/storage/folder-adapter.js.map +1 -1
- package/dist/storage/indexeddb-adapter.js +27 -2
- package/dist/storage/indexeddb-adapter.js.map +1 -1
- package/dist/storage/sqlite-adapter.d.ts +57 -0
- package/dist/storage/sqlite-adapter.d.ts.map +1 -0
- package/dist/storage/sqlite-adapter.js +213 -0
- package/dist/storage/sqlite-adapter.js.map +1 -0
- package/dist/storage/storage-provider.d.ts +21 -2
- package/dist/storage/storage-provider.d.ts.map +1 -1
- package/dist/storage/storage-provider.js +149 -56
- package/dist/storage/storage-provider.js.map +1 -1
- package/dist/sync/sync-engine.d.ts +10 -4
- package/dist/sync/sync-engine.d.ts.map +1 -1
- package/dist/sync/sync-engine.js +120 -38
- package/dist/sync/sync-engine.js.map +1 -1
- package/dist/sync/sync-messages.d.ts +4 -0
- package/dist/sync/sync-messages.d.ts.map +1 -1
- package/dist/sync/sync-messages.js.map +1 -1
- package/dist/types.d.ts +0 -7
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +0 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/step.d.ts +8 -0
- package/dist/utils/step.d.ts.map +1 -0
- package/dist/utils/step.js +15 -0
- package/dist/utils/step.js.map +1 -0
- package/docs/README.md +1 -1
- package/docs/actions.md +41 -2
- package/docs/agents.md +13 -10
- package/docs/automations.md +16 -48
- package/docs/blueprints-and-guides.md +2 -2
- package/docs/bots.md +3 -3
- package/docs/building-an-app.md +16 -0
- package/docs/collections.md +2 -4
- package/docs/computed.md +1 -2
- package/docs/node.md +112 -39
- package/docs/proposing-collections.md +3 -3
- package/docs/sign-in.md +45 -52
- package/docs/spaces.md +0 -5
- package/docs/standard-library.md +20 -8
- package/docs/storage.md +78 -12
- package/docs/usernames.md +3 -3
- package/package.json +7 -13
- package/dist/elements/auth-styles.d.ts +0 -18
- package/dist/elements/auth-styles.d.ts.map +0 -1
- package/dist/elements/auth-styles.js +0 -206
- package/dist/elements/auth-styles.js.map +0 -1
- package/dist/elements/dom.d.ts +0 -29
- package/dist/elements/dom.d.ts.map +0 -1
- package/dist/elements/dom.js +0 -91
- package/dist/elements/dom.js.map +0 -1
- package/dist/elements/index.d.ts +0 -13
- package/dist/elements/index.d.ts.map +0 -1
- package/dist/elements/index.js +0 -11
- package/dist/elements/index.js.map +0 -1
- package/dist/elements/minca-auth.d.ts +0 -55
- package/dist/elements/minca-auth.d.ts.map +0 -1
- package/dist/elements/minca-auth.js +0 -768
- package/dist/elements/minca-auth.js.map +0 -1
- package/dist/node/actions.d.ts +0 -85
- package/dist/node/actions.d.ts.map +0 -1
- package/dist/node/actions.js +0 -921
- package/dist/node/actions.js.map +0 -1
- package/dist/node/host.d.ts +0 -187
- package/dist/node/host.d.ts.map +0 -1
- package/dist/node/host.js +0 -818
- package/dist/node/host.js.map +0 -1
- package/dist/node/usage.d.ts +0 -32
- package/dist/node/usage.d.ts.map +0 -1
- package/dist/node/usage.js +0 -217
- package/dist/node/usage.js.map +0 -1
- package/dist/node/watch-notifications.d.ts +0 -19
- package/dist/node/watch-notifications.d.ts.map +0 -1
- package/dist/node/watch-notifications.js +0 -128
- package/dist/node/watch-notifications.js.map +0 -1
- package/dist/schemas/automations.d.ts +0 -390
- package/dist/schemas/automations.d.ts.map +0 -1
- package/dist/schemas/automations.js +0 -619
- package/dist/schemas/automations.js.map +0 -1
- package/dist/schemas/blueprints.d.ts +0 -122
- package/dist/schemas/blueprints.d.ts.map +0 -1
- package/dist/schemas/blueprints.js +0 -337
- package/dist/schemas/blueprints.js.map +0 -1
- package/dist/schemas/choosing.d.ts +0 -19
- package/dist/schemas/choosing.d.ts.map +0 -1
- package/dist/schemas/choosing.js +0 -69
- package/dist/schemas/choosing.js.map +0 -1
- package/dist/schemas/connectors.d.ts +0 -202
- package/dist/schemas/connectors.d.ts.map +0 -1
- package/dist/schemas/connectors.js +0 -140
- package/dist/schemas/connectors.js.map +0 -1
- package/dist/schemas/cron.d.ts +0 -14
- package/dist/schemas/cron.d.ts.map +0 -1
- package/dist/schemas/cron.js +0 -75
- package/dist/schemas/cron.js.map +0 -1
- package/dist/schemas/geo.d.ts +0 -63
- package/dist/schemas/geo.d.ts.map +0 -1
- package/dist/schemas/geo.js +0 -131
- package/dist/schemas/geo.js.map +0 -1
- package/dist/schemas/guides.d.ts +0 -26
- package/dist/schemas/guides.d.ts.map +0 -1
- package/dist/schemas/guides.js +0 -33
- package/dist/schemas/guides.js.map +0 -1
- package/dist/schemas/library/annotations.d.ts +0 -616
- package/dist/schemas/library/annotations.d.ts.map +0 -1
- package/dist/schemas/library/annotations.js +0 -156
- package/dist/schemas/library/annotations.js.map +0 -1
- package/dist/schemas/library/collections.d.ts +0 -211
- package/dist/schemas/library/collections.d.ts.map +0 -1
- package/dist/schemas/library/collections.js +0 -57
- package/dist/schemas/library/collections.js.map +0 -1
- package/dist/schemas/library/community.d.ts +0 -1136
- package/dist/schemas/library/community.d.ts.map +0 -1
- package/dist/schemas/library/community.js +0 -315
- package/dist/schemas/library/community.js.map +0 -1
- package/dist/schemas/library/life.d.ts +0 -1440
- package/dist/schemas/library/life.d.ts.map +0 -1
- package/dist/schemas/library/life.js +0 -202
- package/dist/schemas/library/life.js.map +0 -1
- package/dist/schemas/library/media.d.ts +0 -1002
- package/dist/schemas/library/media.d.ts.map +0 -1
- package/dist/schemas/library/media.js +0 -110
- package/dist/schemas/library/media.js.map +0 -1
- package/dist/schemas/library/money.d.ts +0 -1221
- package/dist/schemas/library/money.d.ts.map +0 -1
- package/dist/schemas/library/money.js +0 -168
- package/dist/schemas/library/money.js.map +0 -1
- package/dist/schemas/library/planning.d.ts +0 -1107
- package/dist/schemas/library/planning.d.ts.map +0 -1
- package/dist/schemas/library/planning.js +0 -214
- package/dist/schemas/library/planning.js.map +0 -1
- package/dist/schemas/library/publishing.d.ts +0 -1499
- package/dist/schemas/library/publishing.d.ts.map +0 -1
- package/dist/schemas/library/publishing.js +0 -285
- package/dist/schemas/library/publishing.js.map +0 -1
- package/dist/schemas/library/social.d.ts +0 -1257
- package/dist/schemas/library/social.d.ts.map +0 -1
- package/dist/schemas/library/social.js +0 -147
- package/dist/schemas/library/social.js.map +0 -1
- package/dist/schemas/standard.d.ts +0 -21
- package/dist/schemas/standard.d.ts.map +0 -1
- package/dist/schemas/standard.js +0 -39
- package/dist/schemas/standard.js.map +0 -1
- package/dist/session/auth.d.ts +0 -411
- package/dist/session/auth.d.ts.map +0 -1
- package/dist/session/auth.js +0 -1529
- package/dist/session/auth.js.map +0 -1
- package/dist/session/credentials.d.ts +0 -30
- package/dist/session/credentials.d.ts.map +0 -1
- package/dist/session/credentials.js +0 -63
- package/dist/session/credentials.js.map +0 -1
- package/dist/session/password-strength.d.ts +0 -22
- package/dist/session/password-strength.d.ts.map +0 -1
- package/dist/session/password-strength.js +0 -130
- package/dist/session/password-strength.js.map +0 -1
package/dist/schemas/choosing.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { isRecord } from '../utils/guards.js';
|
|
2
|
-
/** What to use for what, one line each */
|
|
3
|
-
export const CHOOSING = Object.freeze([
|
|
4
|
-
'Any file (a photo, video, recording, PDF): std.file. On a record, link it "about" that record.',
|
|
5
|
-
'A group that exists while empty (a folder, album, playlist, category, checklist): std.list, with a std.list-item "in" it, "about" each member.',
|
|
6
|
-
'A loose label on a record (#urgent): std.tag.',
|
|
7
|
-
'Something to do: std.task, "in" a std.column on a board.',
|
|
8
|
-
'Something happening at a time: std.event; answers to it: std.rsvp.',
|
|
9
|
-
'Chat, in order: std.message, "in" a std.channel when there are several. A remark on a record: std.comment. A feed: std.post.',
|
|
10
|
-
'A quick question: std.poll and std.vote. A decision: std.proposal, std.ballot and std.decision.',
|
|
11
|
-
'Taking something on, first come (a task, a slot to book, an item to bring): std.claim.',
|
|
12
|
-
'More fields on a standard record: a collection of your own with an "about" link to it and onePer ["link:about"]. Never a copy of the standard one.',
|
|
13
|
-
'Where a record sits (a channel, column, list, calendar): the link role "in".',
|
|
14
|
-
]);
|
|
15
|
-
/** A definition's fields, when its schema is JSON Schema; a validator's (Zod and the like) say none */
|
|
16
|
-
const propertiesOf = (definition) => {
|
|
17
|
-
const { schema } = definition;
|
|
18
|
-
return isRecord(schema) && isRecord(schema.properties) ? schema.properties : {};
|
|
19
|
-
};
|
|
20
|
-
/** Whether a field holds a file, as `records.addFile` gives one */
|
|
21
|
-
const holdsFile = (definition) => Object.values(propertiesOf(definition)).some((field) => isRecord(field) &&
|
|
22
|
-
isRecord(field.properties) &&
|
|
23
|
-
'hash' in field.properties &&
|
|
24
|
-
'mime' in field.properties);
|
|
25
|
-
/** Link roles that say where a record sits, which the library calls `in` */
|
|
26
|
-
const PLACES = [
|
|
27
|
-
'folder',
|
|
28
|
-
'album',
|
|
29
|
-
'playlist',
|
|
30
|
-
'category',
|
|
31
|
-
'channel',
|
|
32
|
-
'column',
|
|
33
|
-
'board',
|
|
34
|
-
'project',
|
|
35
|
-
'calendar',
|
|
36
|
-
'list',
|
|
37
|
-
];
|
|
38
|
-
/**
|
|
39
|
-
* What in a collection of an app's own looks like one the library already
|
|
40
|
-
* has, each as a sentence to show the agent proposing it. Not a refusal: an
|
|
41
|
-
* app may have its reasons, and the person applying the blueprint decides.
|
|
42
|
-
*/
|
|
43
|
-
export function lookalikes(definition) {
|
|
44
|
-
if (definition.name.startsWith('std.'))
|
|
45
|
-
return [];
|
|
46
|
-
const fields = new Set(Object.keys(propertiesOf(definition)));
|
|
47
|
-
const has = (...names) => names.some((name) => fields.has(name));
|
|
48
|
-
const said = [];
|
|
49
|
-
const twin = (std, why) => said.push(`${definition.name} ${why}, like ${std}. Use ${std} so other apps read these records; ` +
|
|
50
|
-
`for fields of your own, keep a collection about each ${std} record instead.`);
|
|
51
|
-
if (holdsFile(definition) && !has('title', 'question', 'price'))
|
|
52
|
-
twin('std.file', 'keeps a file');
|
|
53
|
-
else if (has('start', 'startsAt') && has('title', 'name'))
|
|
54
|
-
twin('std.event', 'is something at a time');
|
|
55
|
-
else if (has('title') && has('done', 'due', 'assignees', 'status'))
|
|
56
|
-
twin('std.task', 'is something to do');
|
|
57
|
-
else if (has('question') && has('options'))
|
|
58
|
-
twin('std.poll', 'asks a question with options');
|
|
59
|
-
else if (has('emoji') && fields.size <= 2)
|
|
60
|
-
twin('std.reaction', 'is a reaction');
|
|
61
|
-
else if (has('label', 'tag') && fields.size <= 2)
|
|
62
|
-
twin('std.tag', 'is a label');
|
|
63
|
-
for (const role of Object.keys(definition.links ?? {}))
|
|
64
|
-
if (PLACES.includes(role))
|
|
65
|
-
said.push(`${definition.name} says where a record sits with "${role}": the library calls that link "in", ` +
|
|
66
|
-
'so other apps follow it.');
|
|
67
|
-
return said;
|
|
68
|
-
}
|
|
69
|
-
//# sourceMappingURL=choosing.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"choosing.js","sourceRoot":"","sources":["../../src/schemas/choosing.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C,0CAA0C;AAC1C,MAAM,CAAC,MAAM,QAAQ,GAA0B,MAAM,CAAC,MAAM,CAAC;IAC3D,gGAAgG;IAChG,gJAAgJ;IAChJ,+CAA+C;IAC/C,0DAA0D;IAC1D,oEAAoE;IACpE,8HAA8H;IAC9H,iGAAiG;IACjG,wFAAwF;IACxF,oJAAoJ;IACpJ,8EAA8E;CAC/E,CAAC,CAAC;AAEH,uGAAuG;AACvG,MAAM,YAAY,GAAG,CAAC,UAA4B,EAAqC,EAAE;IACvF,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC;IAC9B,OAAO,QAAQ,CAAC,MAAM,CAAC,IAAI,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC;AAClF,CAAC,CAAC;AAEF,mEAAmE;AACnE,MAAM,SAAS,GAAG,CAAC,UAA4B,EAAW,EAAE,CAC1D,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAC1C,CAAC,KAAK,EAAE,EAAE,CAC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BAAwB,CAAC,CAAC;SAClG,IAAI,GAAG,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,CAAC;QAAE,IAAI,CAAC,UAAU,EAAE,oBAAoB,CAAC,CAAC;SACtG,IAAI,GAAG,CAAC,UAAU,CAAC,IAAI,GAAG,CAAC,SAAS,CAAC;QAAE,IAAI,CAAC,UAAU,EAAE,8BAA8B,CAAC,CAAC;SACxF,IAAI,GAAG,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,IAAI,IAAI,CAAC;QAAE,IAAI,CAAC,cAAc,EAAE,eAAe,CAAC,CAAC;SAC5E,IAAI,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,IAAI,IAAI,CAAC;QAAE,IAAI,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;IAChF,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,IAAI,EAAE,CAAC;QACpD,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;YACvB,IAAI,CAAC,IAAI,CACP,GAAG,UAAU,CAAC,IAAI,mCAAmC,IAAI,uCAAuC;gBAC9F,0BAA0B,CAC7B,CAAC;IACN,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Connectors: a bot reaching a service outside the space for its community.
|
|
3
|
-
* Which services is each host's to offer, named in its description by an id
|
|
4
|
-
* (`kind`) and a name. Someone who may configure the bot asks with a `std.connect`;
|
|
5
|
-
* the bot's host checks it, sends them through the service's own consent
|
|
6
|
-
* screen, and the bot says what is connected in its own `std.connector`.
|
|
7
|
-
*
|
|
8
|
-
* No secret is kept here. The host holds what reaches the service; a
|
|
9
|
-
* `std.connect` carries only the hash of a secret the asker's browser keeps.
|
|
10
|
-
*
|
|
11
|
-
* Not protocol for peers: a peer that has never heard of connectors syncs and
|
|
12
|
-
* judges these records like any other. What a host checks of a `std.connect`
|
|
13
|
-
* is in spec/08-hosting.md §3; see `packages/core/docs/bots.md`.
|
|
14
|
-
*/
|
|
15
|
-
import type { BodyOf } from '../query/types.js';
|
|
16
|
-
import type { P2PNode } from '../node/types.js';
|
|
17
|
-
/**
|
|
18
|
-
* Whether `who` may configure `bot` in a space: tell it what to do, give it
|
|
19
|
-
* instructions, connect it to a service. Not the bot itself; someone who
|
|
20
|
-
* holds the grant to instruct bots and every role the bot holds, so nobody
|
|
21
|
-
* reaches past their own grants through it. Asked of `node`'s view of the space; a bot, its host and an app
|
|
22
|
-
* all ask this one.
|
|
23
|
-
*/
|
|
24
|
-
export declare function mayConfigure(node: P2PNode, space: string, bot: string, who: string): Promise<boolean>;
|
|
25
|
-
/** Whether `who` holds every role `bot` holds in a space */
|
|
26
|
-
export declare function holdsBotRoles(node: P2PNode, space: string, bot: string, who: string): Promise<boolean>;
|
|
27
|
-
/** How long a request may stand, from when it was written: long enough for a consent screen */
|
|
28
|
-
export declare const CONNECT_REQUEST_SECONDS = 600;
|
|
29
|
-
/**
|
|
30
|
-
* Someone asking to connect a bot to a service, or to disconnect it. Counts
|
|
31
|
-
* only when its writer may configure the bot; its host checks that.
|
|
32
|
-
*/
|
|
33
|
-
export declare const connect: {
|
|
34
|
-
readonly name: "std.connect";
|
|
35
|
-
readonly title: "Connect request";
|
|
36
|
-
readonly description: "Someone asking to connect a bot to a service, or to disconnect it.";
|
|
37
|
-
readonly schema: {
|
|
38
|
-
readonly type: "object";
|
|
39
|
-
readonly properties: {
|
|
40
|
-
readonly bot: {
|
|
41
|
-
type: 'string';
|
|
42
|
-
minLength?: number | undefined;
|
|
43
|
-
maxLength: number;
|
|
44
|
-
} & {
|
|
45
|
-
readonly 'x-kind': "did";
|
|
46
|
-
};
|
|
47
|
-
readonly kind: {
|
|
48
|
-
type: 'string';
|
|
49
|
-
minLength?: number | undefined;
|
|
50
|
-
maxLength: number;
|
|
51
|
-
};
|
|
52
|
-
readonly verifier: {
|
|
53
|
-
type: 'string';
|
|
54
|
-
minLength?: number | undefined;
|
|
55
|
-
maxLength: number;
|
|
56
|
-
};
|
|
57
|
-
readonly expires: {
|
|
58
|
-
type: 'string';
|
|
59
|
-
minLength?: number | undefined;
|
|
60
|
-
maxLength: number;
|
|
61
|
-
} & {
|
|
62
|
-
readonly 'x-kind': "when";
|
|
63
|
-
};
|
|
64
|
-
readonly disconnect: {
|
|
65
|
-
readonly type: "boolean";
|
|
66
|
-
};
|
|
67
|
-
};
|
|
68
|
-
readonly required: readonly ["bot", "kind", "expires"];
|
|
69
|
-
};
|
|
70
|
-
} & import("../index.js").Typed<{
|
|
71
|
-
readonly bot: string;
|
|
72
|
-
readonly kind: string;
|
|
73
|
-
readonly verifier?: string | undefined;
|
|
74
|
-
readonly expires: string;
|
|
75
|
-
readonly disconnect?: boolean | undefined;
|
|
76
|
-
}>;
|
|
77
|
-
export type Connect = BodyOf<typeof connect>;
|
|
78
|
-
/** What a bot is connected to, in its own words: an app shows one only when the bot wrote it */
|
|
79
|
-
export declare const connector: {
|
|
80
|
-
readonly name: "std.connector";
|
|
81
|
-
readonly title: "Connector";
|
|
82
|
-
readonly description: "A service a bot is connected to, said by the bot.";
|
|
83
|
-
readonly schema: {
|
|
84
|
-
readonly type: "object";
|
|
85
|
-
readonly properties: {
|
|
86
|
-
readonly bot: {
|
|
87
|
-
type: 'string';
|
|
88
|
-
minLength?: number | undefined;
|
|
89
|
-
maxLength: number;
|
|
90
|
-
} & {
|
|
91
|
-
readonly 'x-kind': "did";
|
|
92
|
-
};
|
|
93
|
-
readonly kind: {
|
|
94
|
-
type: 'string';
|
|
95
|
-
minLength?: number | undefined;
|
|
96
|
-
maxLength: number;
|
|
97
|
-
};
|
|
98
|
-
readonly account: {
|
|
99
|
-
type: 'string';
|
|
100
|
-
minLength?: number | undefined;
|
|
101
|
-
maxLength: number;
|
|
102
|
-
};
|
|
103
|
-
readonly reaches: {
|
|
104
|
-
readonly type: "array";
|
|
105
|
-
readonly items: {
|
|
106
|
-
type: 'string';
|
|
107
|
-
minLength?: number | undefined;
|
|
108
|
-
maxLength: number;
|
|
109
|
-
};
|
|
110
|
-
readonly maxItems: 100;
|
|
111
|
-
readonly description: "What it reaches there, as people read it: repositories, calendars, folders";
|
|
112
|
-
};
|
|
113
|
-
readonly by: {
|
|
114
|
-
type: 'string';
|
|
115
|
-
minLength?: number | undefined;
|
|
116
|
-
maxLength: number;
|
|
117
|
-
} & {
|
|
118
|
-
readonly 'x-kind': "did";
|
|
119
|
-
};
|
|
120
|
-
readonly since: {
|
|
121
|
-
type: 'string';
|
|
122
|
-
minLength?: number | undefined;
|
|
123
|
-
maxLength: number;
|
|
124
|
-
} & {
|
|
125
|
-
readonly 'x-kind': "when";
|
|
126
|
-
};
|
|
127
|
-
};
|
|
128
|
-
readonly required: readonly ["bot", "kind", "account", "by", "since"];
|
|
129
|
-
};
|
|
130
|
-
readonly rules: {
|
|
131
|
-
readonly onePer: readonly ["@author", "kind"];
|
|
132
|
-
};
|
|
133
|
-
} & import("../index.js").Typed<{
|
|
134
|
-
readonly bot: string;
|
|
135
|
-
readonly kind: string;
|
|
136
|
-
readonly account: string;
|
|
137
|
-
readonly reaches?: readonly string[] | undefined;
|
|
138
|
-
readonly by: string;
|
|
139
|
-
readonly since: string;
|
|
140
|
-
}>;
|
|
141
|
-
export type Connector = BodyOf<typeof connector>;
|
|
142
|
-
/** The most a bot's instructions may say, in characters */
|
|
143
|
-
export declare const BOT_INSTRUCTIONS_MAX = 2000;
|
|
144
|
-
/**
|
|
145
|
-
* How a community wants its bot to be: a name to go by, a tone, what to know.
|
|
146
|
-
* Read into the bot's system prompt after its fixed rules, so it can't undo
|
|
147
|
-
* them, and only from someone who may configure the bot. One per writer, so
|
|
148
|
-
* nobody's words overwrite another's; the bot takes the newest that counts.
|
|
149
|
-
*/
|
|
150
|
-
export declare const botSettings: {
|
|
151
|
-
readonly name: "std.bot";
|
|
152
|
-
readonly title: "Bot";
|
|
153
|
-
readonly description: "How a community wants its bot to be, in the words of someone who may configure it.";
|
|
154
|
-
readonly schema: {
|
|
155
|
-
readonly type: "object";
|
|
156
|
-
readonly properties: {
|
|
157
|
-
bot: {
|
|
158
|
-
type: 'string';
|
|
159
|
-
minLength?: number | undefined;
|
|
160
|
-
maxLength: number;
|
|
161
|
-
} & {
|
|
162
|
-
readonly 'x-kind': "did";
|
|
163
|
-
};
|
|
164
|
-
instructions: {
|
|
165
|
-
type: 'string';
|
|
166
|
-
minLength?: number | undefined;
|
|
167
|
-
maxLength: number;
|
|
168
|
-
};
|
|
169
|
-
};
|
|
170
|
-
readonly required: readonly ["bot", "instructions"];
|
|
171
|
-
};
|
|
172
|
-
readonly rules: {
|
|
173
|
-
readonly onePer: readonly ["@author", "bot"];
|
|
174
|
-
};
|
|
175
|
-
} & import("../index.js").Typed<{
|
|
176
|
-
readonly bot: string;
|
|
177
|
-
readonly instructions: string;
|
|
178
|
-
}>;
|
|
179
|
-
export type BotSettings = BodyOf<typeof botSettings>;
|
|
180
|
-
/** A request written, and the secret that goes with it: kept by the asker, never written down */
|
|
181
|
-
export interface ConnectAsk {
|
|
182
|
-
readonly space: string;
|
|
183
|
-
readonly bot: string;
|
|
184
|
-
/** The service: a connector id the bot's host names */
|
|
185
|
-
readonly kind: string;
|
|
186
|
-
readonly request: string;
|
|
187
|
-
readonly secret: string;
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* Writes a request to connect a bot to a service, or with `disconnect` to
|
|
191
|
-
* disconnect it, for the bot's host to check. The secret it returns, 32
|
|
192
|
-
* random bytes, is for the host's page alone: it is the only proof the
|
|
193
|
-
* request is the asker's. The request stands for nine minutes.
|
|
194
|
-
*/
|
|
195
|
-
export declare function askToConnect(node: P2PNode, space: string, bot: string, kind: string, options?: {
|
|
196
|
-
readonly disconnect?: boolean;
|
|
197
|
-
}): Promise<ConnectAsk>;
|
|
198
|
-
/** The host's page that connects a bot, for a request `askToConnect` wrote */
|
|
199
|
-
export declare function connectPage(hostUrl: string, ask: ConnectAsk): string;
|
|
200
|
-
/** Asks a bot's host to disconnect it, for a request `askToConnect` wrote with `disconnect`. Throws what the host said when it refuses. */
|
|
201
|
-
export declare function askToDisconnect(hostUrl: string, ask: ConnectAsk): Promise<void>;
|
|
202
|
-
//# sourceMappingURL=connectors.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"connectors.d.ts","sourceRoot":"","sources":["../../src/schemas/connectors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAOhD;;;;;;GAMG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAK3G;AAED,4DAA4D;AAC5D,wBAAsB,aAAa,CACjC,IAAI,EAAE,OAAO,EACb,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,OAAO,CAAC,CAKlB;AAED,+FAA+F;AAC/F,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAE3C;;;GAGG;AACH,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmBlB,CAAC;AACH,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,OAAO,CAAC,CAAC;AAE7C,gGAAgG;AAChG,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsBpB,CAAC;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,SAAS,CAAC,CAAC;AAEjD,2DAA2D;AAC3D,eAAO,MAAM,oBAAoB,OAAO,CAAC;AAEzC;;;;;GAKG;AACH,eAAO,MAAM,WAAW;;;;;;;YAOlB,GAAG;;;;;;;YACH,YAAY;;;;;;;;;;;;;;EAKhB,CAAC;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,WAAW,CAAC,CAAC;AAErD,iGAAiG;AACjG,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,uDAAuD;IACvD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED;;;;;GAKG;AACH,wBAAsB,YAAY,CAChC,IAAI,EAAE,OAAO,EACb,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE;IAAE,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAA;CAAO,GAC9C,OAAO,CAAC,UAAU,CAAC,CAarB;AAED,8EAA8E;AAC9E,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,GAAG,MAAM,CAGpE;AAED,2IAA2I;AAC3I,wBAAsB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAUrF"}
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import { base64UrlEncode, utf8Encode } from '../utils/encoding.js';
|
|
2
|
-
import { sha256 } from '../utils/hash.js';
|
|
3
|
-
import { isObject } from '../utils/guards.js';
|
|
4
|
-
import { define, person, text, when, words } from './fragments.js';
|
|
5
|
-
import { INSTRUCT } from './automations.js';
|
|
6
|
-
/**
|
|
7
|
-
* Whether `who` may configure `bot` in a space: tell it what to do, give it
|
|
8
|
-
* instructions, connect it to a service. Not the bot itself; someone who
|
|
9
|
-
* holds the grant to instruct bots and every role the bot holds, so nobody
|
|
10
|
-
* reaches past their own grants through it. Asked of `node`'s view of the space; a bot, its host and an app
|
|
11
|
-
* all ask this one.
|
|
12
|
-
*/
|
|
13
|
-
export async function mayConfigure(node, space, bot, who) {
|
|
14
|
-
// Never the bot itself: one steered run could otherwise leave itself instructions that count.
|
|
15
|
-
if (who === bot)
|
|
16
|
-
return false;
|
|
17
|
-
if (!(await node.spaces.may(space, INSTRUCT, {}, who).catch(() => false)))
|
|
18
|
-
return false;
|
|
19
|
-
return holdsBotRoles(node, space, bot, who);
|
|
20
|
-
}
|
|
21
|
-
/** Whether `who` holds every role `bot` holds in a space */
|
|
22
|
-
export async function holdsBotRoles(node, space, bot, who) {
|
|
23
|
-
const { members } = await node.spaces.access(space);
|
|
24
|
-
const roles = members.find((member) => member.did === bot)?.roles ?? [];
|
|
25
|
-
for (const role of roles)
|
|
26
|
-
if (!(await node.spaces.holdsRole(space, role, who)))
|
|
27
|
-
return false;
|
|
28
|
-
return true;
|
|
29
|
-
}
|
|
30
|
-
/** How long a request may stand, from when it was written: long enough for a consent screen */
|
|
31
|
-
export const CONNECT_REQUEST_SECONDS = 600;
|
|
32
|
-
/**
|
|
33
|
-
* Someone asking to connect a bot to a service, or to disconnect it. Counts
|
|
34
|
-
* only when its writer may configure the bot; its host checks that.
|
|
35
|
-
*/
|
|
36
|
-
export const connect = define({
|
|
37
|
-
name: 'std.connect',
|
|
38
|
-
title: 'Connect request',
|
|
39
|
-
description: 'Someone asking to connect a bot to a service, or to disconnect it.',
|
|
40
|
-
schema: {
|
|
41
|
-
type: 'object',
|
|
42
|
-
properties: {
|
|
43
|
-
bot: person('The bot to connect'),
|
|
44
|
-
kind: text(40, 'The service: a connector id the host names, of lowercase letters, digits and dashes', 1),
|
|
45
|
-
verifier: text(64, 'base64url(SHA-256(secret)): the secret stays in the asker’s browser', 43),
|
|
46
|
-
expires: when('After this it counts for nothing'),
|
|
47
|
-
disconnect: { type: 'boolean' },
|
|
48
|
-
},
|
|
49
|
-
required: ['bot', 'kind', 'expires'],
|
|
50
|
-
},
|
|
51
|
-
});
|
|
52
|
-
/** What a bot is connected to, in its own words: an app shows one only when the bot wrote it */
|
|
53
|
-
export const connector = define({
|
|
54
|
-
name: 'std.connector',
|
|
55
|
-
title: 'Connector',
|
|
56
|
-
description: 'A service a bot is connected to, said by the bot.',
|
|
57
|
-
schema: {
|
|
58
|
-
type: 'object',
|
|
59
|
-
properties: {
|
|
60
|
-
bot: person('The bot, which writes this'),
|
|
61
|
-
kind: text(40, 'The service, as in the request', 1),
|
|
62
|
-
account: words(100, 'Whose account at the service: an organisation, a user, an email address'),
|
|
63
|
-
reaches: {
|
|
64
|
-
type: 'array',
|
|
65
|
-
items: words(200),
|
|
66
|
-
maxItems: 100,
|
|
67
|
-
description: 'What it reaches there, as people read it: repositories, calendars, folders',
|
|
68
|
-
},
|
|
69
|
-
by: person('Who connected it'),
|
|
70
|
-
since: when(),
|
|
71
|
-
},
|
|
72
|
-
required: ['bot', 'kind', 'account', 'by', 'since'],
|
|
73
|
-
},
|
|
74
|
-
rules: { onePer: ['@author', 'kind'] },
|
|
75
|
-
});
|
|
76
|
-
/** The most a bot's instructions may say, in characters */
|
|
77
|
-
export const BOT_INSTRUCTIONS_MAX = 2000;
|
|
78
|
-
/**
|
|
79
|
-
* How a community wants its bot to be: a name to go by, a tone, what to know.
|
|
80
|
-
* Read into the bot's system prompt after its fixed rules, so it can't undo
|
|
81
|
-
* them, and only from someone who may configure the bot. One per writer, so
|
|
82
|
-
* nobody's words overwrite another's; the bot takes the newest that counts.
|
|
83
|
-
*/
|
|
84
|
-
export const botSettings = define({
|
|
85
|
-
name: 'std.bot',
|
|
86
|
-
title: 'Bot',
|
|
87
|
-
description: 'How a community wants its bot to be, in the words of someone who may configure it.',
|
|
88
|
-
schema: {
|
|
89
|
-
type: 'object',
|
|
90
|
-
properties: {
|
|
91
|
-
bot: person('The bot'),
|
|
92
|
-
instructions: text(BOT_INSTRUCTIONS_MAX, 'What the bot is told, after its own rules'),
|
|
93
|
-
},
|
|
94
|
-
required: ['bot', 'instructions'],
|
|
95
|
-
},
|
|
96
|
-
rules: { onePer: ['@author', 'bot'] },
|
|
97
|
-
});
|
|
98
|
-
/**
|
|
99
|
-
* Writes a request to connect a bot to a service, or with `disconnect` to
|
|
100
|
-
* disconnect it, for the bot's host to check. The secret it returns, 32
|
|
101
|
-
* random bytes, is for the host's page alone: it is the only proof the
|
|
102
|
-
* request is the asker's. The request stands for nine minutes.
|
|
103
|
-
*/
|
|
104
|
-
export async function askToConnect(node, space, bot, kind, options = {}) {
|
|
105
|
-
const secret = base64UrlEncode(globalThis.crypto.getRandomValues(new Uint8Array(32)));
|
|
106
|
-
const verifier = base64UrlEncode(await sha256(utf8Encode(secret)));
|
|
107
|
-
// A little under the most a host takes, for clocks that differ.
|
|
108
|
-
const expires = new Date(Date.now() + (CONNECT_REQUEST_SECONDS - 60) * 1000).toISOString();
|
|
109
|
-
const record = await node.records.put(space, connect, {
|
|
110
|
-
bot,
|
|
111
|
-
kind,
|
|
112
|
-
verifier,
|
|
113
|
-
expires,
|
|
114
|
-
...(options.disconnect ? { disconnect: true } : {}),
|
|
115
|
-
});
|
|
116
|
-
return { space, bot, kind, request: record.key, secret };
|
|
117
|
-
}
|
|
118
|
-
/** The host's page that connects a bot, for a request `askToConnect` wrote */
|
|
119
|
-
export function connectPage(hostUrl, ask) {
|
|
120
|
-
const query = new URLSearchParams({ space: ask.space, request: ask.request, secret: ask.secret });
|
|
121
|
-
return `${botAddress(hostUrl, ask, 'connect')}?${query}`;
|
|
122
|
-
}
|
|
123
|
-
/** Asks a bot's host to disconnect it, for a request `askToConnect` wrote with `disconnect`. Throws what the host said when it refuses. */
|
|
124
|
-
export async function askToDisconnect(hostUrl, ask) {
|
|
125
|
-
const res = await fetch(botAddress(hostUrl, ask, 'disconnect'), {
|
|
126
|
-
method: 'POST',
|
|
127
|
-
headers: { 'content-type': 'application/json' },
|
|
128
|
-
body: JSON.stringify({ space: ask.space, request: ask.request, secret: ask.secret }),
|
|
129
|
-
});
|
|
130
|
-
if (res.ok)
|
|
131
|
-
return;
|
|
132
|
-
const answer = await res.json().catch(() => null);
|
|
133
|
-
const error = isObject(answer) && typeof answer.error === 'string' ? answer.error : null;
|
|
134
|
-
throw new Error(error ?? `The host answered ${res.status}`);
|
|
135
|
-
}
|
|
136
|
-
function botAddress(hostUrl, ask, action) {
|
|
137
|
-
const host = hostUrl.replace(/\/+$/, '');
|
|
138
|
-
return `${host}/host/bots/${encodeURIComponent(ask.bot)}/${action}/${encodeURIComponent(ask.kind)}`;
|
|
139
|
-
}
|
|
140
|
-
//# sourceMappingURL=connectors.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"connectors.js","sourceRoot":"","sources":["../../src/schemas/connectors.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,IAAa,EAAE,KAAa,EAAE,GAAW,EAAE,GAAW;IACvF,8FAA8F;IAC9F,IAAI,GAAG,KAAK,GAAG;QAAE,OAAO,KAAK,CAAC;IAC9B,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC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as/cron.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* When a rule runs by itself (`every`): five cron fields, minute hour day
|
|
3
|
-
* month weekday, in the runner's local time.
|
|
4
|
-
*/
|
|
5
|
-
/** Why a cron version can't be read, or null */
|
|
6
|
-
export declare function checkCron(version: string): string | null;
|
|
7
|
-
/** Whether a cron version names this minute, in local time. As in cron, a day and a weekday both given means either. */
|
|
8
|
-
export declare function cronMatches(version: string, at: Date): boolean;
|
|
9
|
-
/** Times people pick most, in words, for a builder to offer before five cron fields */
|
|
10
|
-
export declare const SCHEDULES: ReadonlyArray<{
|
|
11
|
-
readonly value: string;
|
|
12
|
-
readonly label: string;
|
|
13
|
-
}>;
|
|
14
|
-
//# sourceMappingURL=cron.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cron.d.ts","sourceRoot":"","sources":["../../src/schemas/cron.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA4BH,gDAAgD;AAChD,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAGxD;AAED,wHAAwH;AACxH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,GAAG,OAAO,CAG9D;AA8BD,uFAAuF;AACvF,eAAO,MAAM,SAAS,EAAE,aAAa,CAAC;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAKvF,CAAC"}
|
package/dist/schemas/cron.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* When a rule runs by itself (`every`): five cron fields, minute hour day
|
|
3
|
-
* month weekday, in the runner's local time.
|
|
4
|
-
*/
|
|
5
|
-
const CRON_FIELDS = [
|
|
6
|
-
{ name: 'minute', min: 0, max: 59 },
|
|
7
|
-
{ name: 'hour', min: 0, max: 23 },
|
|
8
|
-
{ name: 'day', min: 1, max: 31 },
|
|
9
|
-
{ name: 'month', min: 1, max: 12 },
|
|
10
|
-
{ name: 'weekday', min: 0, max: 7 },
|
|
11
|
-
];
|
|
12
|
-
/** The values one cron field allows, or a reason it can't be read */
|
|
13
|
-
function cronField(text, min, max) {
|
|
14
|
-
const allowed = new Set();
|
|
15
|
-
for (const part of text.split(',')) {
|
|
16
|
-
const found = /^(\*|(\d+)(?:-(\d+))?)(?:\/(\d+))?$/.exec(part);
|
|
17
|
-
if (!found)
|
|
18
|
-
return `"${part}" is not a number, a range, * or a step`;
|
|
19
|
-
const [, all, from, to, step] = found;
|
|
20
|
-
const start = all === '*' ? min : Number(from);
|
|
21
|
-
const end = all === '*' ? max : to !== undefined ? Number(to) : step !== undefined ? max : start;
|
|
22
|
-
const by = step !== undefined ? Number(step) : 1;
|
|
23
|
-
if (start < min || end > max || start > end || by < 1)
|
|
24
|
-
return `"${part}" is outside ${min}–${max}`;
|
|
25
|
-
for (let value = start; value <= end; value += by)
|
|
26
|
-
allowed.add(value);
|
|
27
|
-
}
|
|
28
|
-
return allowed;
|
|
29
|
-
}
|
|
30
|
-
/** Why a cron version can't be read, or null */
|
|
31
|
-
export function checkCron(version) {
|
|
32
|
-
const read = readCron(version);
|
|
33
|
-
return typeof read === 'string' ? read : null;
|
|
34
|
-
}
|
|
35
|
-
/** Whether a cron version names this minute, in local time. As in cron, a day and a weekday both given means either. */
|
|
36
|
-
export function cronMatches(version, at) {
|
|
37
|
-
const read = readCron(version);
|
|
38
|
-
return typeof read !== 'string' && read(at);
|
|
39
|
-
}
|
|
40
|
-
/** A schedule as a test for a minute, or why it can't be read */
|
|
41
|
-
function readCron(version) {
|
|
42
|
-
const parts = version.trim().split(/\s+/);
|
|
43
|
-
if (parts.length !== 5)
|
|
44
|
-
return 'A schedule is five fields: minute hour day month weekday';
|
|
45
|
-
const allowed = new Map();
|
|
46
|
-
for (const [index, field] of CRON_FIELDS.entries()) {
|
|
47
|
-
const read = cronField(parts[index] ?? '', field.min, field.max);
|
|
48
|
-
if (typeof read === 'string')
|
|
49
|
-
return `${field.name}: ${read}`;
|
|
50
|
-
allowed.set(field.name, read);
|
|
51
|
-
}
|
|
52
|
-
// Sunday is 0 or 7.
|
|
53
|
-
if (allowed.get('weekday')?.has(7))
|
|
54
|
-
allowed.get('weekday')?.add(0);
|
|
55
|
-
const has = (name, value) => allowed.get(name)?.has(value) ?? false;
|
|
56
|
-
// Only when both are narrowed does either one do.
|
|
57
|
-
const narrowed = parts[2] !== '*' && parts[4] !== '*';
|
|
58
|
-
return (at) => {
|
|
59
|
-
const onDay = has('day', at.getDate());
|
|
60
|
-
const onWeekday = has('weekday', at.getDay());
|
|
61
|
-
const dayMatches = narrowed ? onDay || onWeekday : onDay && onWeekday;
|
|
62
|
-
return (has('minute', at.getMinutes()) &&
|
|
63
|
-
has('hour', at.getHours()) &&
|
|
64
|
-
has('month', at.getMonth() + 1) &&
|
|
65
|
-
dayMatches);
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
/** Times people pick most, in words, for a builder to offer before five cron fields */
|
|
69
|
-
export const SCHEDULES = [
|
|
70
|
-
{ value: '0 8 * * 1-5', label: 'Weekday mornings at 8' },
|
|
71
|
-
{ value: '0 9 * * 1', label: 'Mondays at 9' },
|
|
72
|
-
{ value: '0 18 * * *', label: 'Every evening at 6' },
|
|
73
|
-
{ value: '0 * * * *', label: 'Every hour' },
|
|
74
|
-
];
|
|
75
|
-
//# sourceMappingURL=cron.js.map
|
package/dist/schemas/cron.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cron.js","sourceRoot":"","sources":["../../src/schemas/cron.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,GAAG;IAClB,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE;IACnC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE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E,aAAa,EAAE,KAAK,EAAE,uBAAuB,EAAE;IACxD,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,cAAc,EAAE;IAC7C,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,oBAAoB,EAAE;IACpD,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,YAAY,EAAE;CAC5C,CAAC"}
|
package/dist/schemas/geo.d.ts
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Where things are, as something a keeper can match without reading.
|
|
3
|
-
*
|
|
4
|
-
* A place in a standard record carries `lat` and `lon`, and with them
|
|
5
|
-
* `cells`: the geohash cells the point is in, one for each precision in
|
|
6
|
-
* {@link CELL_PRECISIONS}. Collections name `place.cells` as a topic, so each
|
|
7
|
-
* cell becomes a blind tag (spec 02 §8), and "listings near here" is a match
|
|
8
|
-
* on a handful of cells: equality only, which is all a tag can do. The exact
|
|
9
|
-
* distance is worked out afterwards, from `lat` and `lon`, by whoever reads
|
|
10
|
-
* the body.
|
|
11
|
-
*
|
|
12
|
-
* Geohash, after Niemeyer (2008): longitude and latitude bits interleaved,
|
|
13
|
-
* longitude first, five to a character of its own base 32 alphabet. A cell's
|
|
14
|
-
* name is a prefix of every cell inside it.
|
|
15
|
-
*/
|
|
16
|
-
/** The precisions a place's `cells` hold, coarsest first: about 156 km, 39 km, 4.9 km and 1.2 km across */
|
|
17
|
-
export declare const CELL_PRECISIONS: readonly [3, 4, 5, 6];
|
|
18
|
-
/** The geohash of a point, `precision` characters long (1–12) */
|
|
19
|
-
export declare function geohash(lat: number, lon: number, precision: number): string;
|
|
20
|
-
/** The box a geohash names, in degrees */
|
|
21
|
-
export interface Cell {
|
|
22
|
-
readonly south: number;
|
|
23
|
-
readonly west: number;
|
|
24
|
-
readonly north: number;
|
|
25
|
-
readonly east: number;
|
|
26
|
-
}
|
|
27
|
-
/** The box a geohash names; throws on a character outside its alphabet */
|
|
28
|
-
export declare function cellOf(hash: string): Cell;
|
|
29
|
-
/** The middle of a geohash's box */
|
|
30
|
-
export declare function centreOf(hash: string): {
|
|
31
|
-
lat: number;
|
|
32
|
-
lon: number;
|
|
33
|
-
};
|
|
34
|
-
/**
|
|
35
|
-
* A cell and the eight around it, at the cell's own precision, each once.
|
|
36
|
-
* Longitude wraps at ±180°; past a pole there is nothing, so a cell at the
|
|
37
|
-
* edge has fewer.
|
|
38
|
-
*/
|
|
39
|
-
export declare function aroundCell(hash: string): string[];
|
|
40
|
-
/** What a place's `cells` hold for a point: its cell at each of {@link CELL_PRECISIONS} */
|
|
41
|
-
export declare const cellsOf: (lat: number, lon: number) => string[];
|
|
42
|
-
/** The distance between two points along the Earth's surface, in kilometres (haversine) */
|
|
43
|
-
export declare function distanceKm(a: {
|
|
44
|
-
readonly lat: number;
|
|
45
|
-
readonly lon: number;
|
|
46
|
-
}, b: {
|
|
47
|
-
readonly lat: number;
|
|
48
|
-
readonly lon: number;
|
|
49
|
-
}): number;
|
|
50
|
-
/**
|
|
51
|
-
* The cells that hold everything within `radiusKm` of a point: the finest of
|
|
52
|
-
* {@link CELL_PRECISIONS} whose cells are at least that wide and tall there,
|
|
53
|
-
* and the eight around the point's own. Something inside the circle is in one
|
|
54
|
-
* of them; not everything in them is inside the circle, so check the distance
|
|
55
|
-
* too. Null when even the coarsest cells are too small (a radius over about
|
|
56
|
-
* 150 km, or near a pole): then there is no shortcut, and every place is a
|
|
57
|
-
* candidate.
|
|
58
|
-
*/
|
|
59
|
-
export declare function cellsAround(lat: number, lon: number, radiusKm: number): {
|
|
60
|
-
precision: number;
|
|
61
|
-
cells: string[];
|
|
62
|
-
} | null;
|
|
63
|
-
//# sourceMappingURL=geo.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"geo.d.ts","sourceRoot":"","sources":["../../src/schemas/geo.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,2GAA2G;AAC3G,eAAO,MAAM,eAA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