@niscorp/moss 0.6.0 → 0.7.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.
Files changed (57) hide show
  1. package/CHANGELOG.md +100 -0
  2. package/DESIGN.md +77 -40
  3. package/DOCS.md +636 -78
  4. package/README.md +2 -2
  5. package/dist/{chunk-VBWNHF4H.cjs → chunk-C2DNDIQX.cjs} +4 -3
  6. package/dist/chunk-C2DNDIQX.cjs.map +1 -0
  7. package/dist/{chunk-R66WUKGC.cjs → chunk-DSTHFSTO.cjs} +1988 -1328
  8. package/dist/chunk-DSTHFSTO.cjs.map +1 -0
  9. package/dist/chunk-F45SFR7W.cjs +903 -0
  10. package/dist/chunk-F45SFR7W.cjs.map +1 -0
  11. package/dist/{chunk-NSK7QSSG.js → chunk-IMZZB4JE.js} +4 -3
  12. package/dist/chunk-IMZZB4JE.js.map +1 -0
  13. package/dist/{chunk-V5YMJL7Z.js → chunk-MTC46PGQ.js} +1971 -1309
  14. package/dist/chunk-MTC46PGQ.js.map +1 -0
  15. package/dist/chunk-MYGVHWS5.js +870 -0
  16. package/dist/chunk-MYGVHWS5.js.map +1 -0
  17. package/dist/{chunk-WKBH3UMB.js → chunk-X2Q546EB.js} +3 -3
  18. package/dist/{chunk-WKBH3UMB.js.map → chunk-X2Q546EB.js.map} +1 -1
  19. package/dist/{chunk-D3YZIAYV.cjs → chunk-Z2VA6AOE.cjs} +5 -5
  20. package/dist/{chunk-D3YZIAYV.cjs.map → chunk-Z2VA6AOE.cjs.map} +1 -1
  21. package/dist/document-AbQUbQaP.d.ts +381 -0
  22. package/dist/document-wHHxIXJz.d.cts +381 -0
  23. package/dist/{index-B411sK9M.d.cts → index-Dml1klpZ.d.cts} +4 -0
  24. package/dist/{index-B411sK9M.d.ts → index-Dml1klpZ.d.ts} +4 -0
  25. package/dist/index.cjs +17 -17
  26. package/dist/index.d.cts +7 -9
  27. package/dist/index.d.ts +7 -9
  28. package/dist/index.js +3 -3
  29. package/dist/integrations.cjs +3 -3
  30. package/dist/integrations.d.cts +1 -1
  31. package/dist/integrations.d.ts +1 -1
  32. package/dist/integrations.js +1 -1
  33. package/dist/node.cjs +8 -8
  34. package/dist/node.d.cts +3 -4
  35. package/dist/node.d.ts +3 -4
  36. package/dist/node.js +4 -4
  37. package/dist/tide.d.cts +1 -1
  38. package/dist/tide.d.ts +1 -1
  39. package/dist/unverified.cjs +3 -3
  40. package/dist/unverified.js +2 -2
  41. package/dist/vite.cjs +9 -9
  42. package/dist/vite.d.cts +6 -1
  43. package/dist/vite.d.ts +6 -1
  44. package/dist/vite.js +4 -4
  45. package/package.json +13 -13
  46. package/dist/app-CUnDcXQu.d.ts +0 -143
  47. package/dist/app-CdANzi2q.d.cts +0 -143
  48. package/dist/chunk-NSK7QSSG.js.map +0 -1
  49. package/dist/chunk-PWUO4RET.js +0 -374
  50. package/dist/chunk-PWUO4RET.js.map +0 -1
  51. package/dist/chunk-R2YPQHQH.cjs +0 -383
  52. package/dist/chunk-R2YPQHQH.cjs.map +0 -1
  53. package/dist/chunk-R66WUKGC.cjs.map +0 -1
  54. package/dist/chunk-V5YMJL7Z.js.map +0 -1
  55. package/dist/chunk-VBWNHF4H.cjs.map +0 -1
  56. package/dist/document-D7nroBww.d.cts +0 -169
  57. package/dist/document-DeTPGBil.d.ts +0 -169
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/runtime/runtime.ts"],"names":["z"],"mappings":";;;;;AAsDO,IAAM,YAAY,CAAC,SAAA,KACxB,cAAc,MAAA,GACV,MAAA,GACA,CAAC,IAAA,KAAS;AACR,EAAA,IAAI;AACF,IAAA,SAAA,CAAU,KAAK,IAAI,CAAA;AAAA,EACrB,SAAS,GAAA,EAAK;AACZ,IAAA,OAAA,CAAQ,KAAA,CAAM,oBAAoB,GAAG,CAAA;AAAA,EACvC;AACF;AAIN,IAAM,YAAA,GAAe,MAAe,OAAO,WAAA,KAAgB,cAAc,WAAA,CAAY,GAAA,EAAI,GAAI,IAAA,CAAK,GAAA,EAAI;AAE/F,IAAM,YAAY,MAAiB;AACxC,EAAA,MAAM,aAAA,GAAgB,IAAA,CAAK,GAAA,EAAI,GAAI,GAAA;AACnC,EAAA,MAAM,KAAK,YAAA,EAAa;AACxB,EAAA,OAAO,EAAE,eAAe,WAAA,EAAa,MAAM,iBAAiB,YAAA,EAAa,GAAI,MAAM,GAAA,EAAI;AACzF;AAEA,IAAM,KAAA,GAAQ,EAAE,MAAA,EAAQA,KAAA,CAAE,QAAO,EAAE;AAE5B,IAAM,mBAAA,GAAsBA,KAAA,CAAE,kBAAA,CAAmB,MAAA,EAAQ;AAAA,EAC9DA,KAAA,CAAE,YAAA,CAAa,EAAE,IAAA,EAAMA,MAAE,OAAA,CAAQ,qBAAqB,CAAA,EAAG,SAAA,EAAWA,KAAA,CAAE,MAAA,EAAO,EAAG,GAAG,OAAO,CAAA;AAAA,EAC1FA,KAAA,CAAE,YAAA,CAAa,EAAE,IAAA,EAAMA,MAAE,OAAA,CAAQ,gBAAgB,CAAA,EAAG,GAAA,EAAKA,KAAA,CAAE,MAAA,EAAO,EAAG,GAAG,OAAO,CAAA;AAAA,EAC/EA,MAAE,YAAA,CAAa,EAAE,MAAMA,KAAA,CAAE,OAAA,CAAQ,OAAO,CAAA,EAAG,SAAA,EAAWA,KAAA,CAAE,MAAA,IAAU,OAAA,EAASA,KAAA,CAAE,QAAO,EAAG,GAAG,OAAO;AACnG,CAAC","file":"chunk-VBWNHF4H.cjs","sourcesContent":["import type { Context, Next } from 'hono';\nimport type { CacheBackend, MutationClient, PgPool, QueryEngineConfig } from '@niscorp/vex';\nimport type { Sequence } from '@niscorp/strata';\nimport { z } from 'zod';\n\nexport type SessionVerifier = (token: string) => string | null | Promise<string | null>;\n\nexport type NiscRuntime = {\n pool: PgPool;\n db: MutationClient;\n cache?: CacheBackend;\n vexConfig?: QueryEngineConfig['config'];\n session: SessionVerifier | 'sessions' | 'dev-open';\n origins?: readonly string[];\n migrations?: 'apply' | 'verify';\n tables?: readonly Sequence[];\n shellIdleMs?: number;\n anonymousShellMax?: number;\n endpointTimeoutMs?: number;\n sessionRevalidateMs?: number;\n identityMax?: number;\n identityIdleMs?: number;\n shellFrameDelta?: boolean;\n socketCompression?: boolean | Record<string, unknown>;\n socketMaxMessageBytes?: number;\n operatorKey?: string;\n\n operatorGate?: (c: Context, next: Next) => Response | void | Promise<Response | void>;\n\n fabric?: Fabric;\n\n telemetry?: Telemetry;\n};\n\nexport type TelemetrySpan = {\n name: string;\n // A JS number cannot hold epoch nanoseconds exactly: the loss is far below\n // the milliseconds measured here.\n startUnixNano: number;\n endUnixNano: number;\n status: 'ok' | 'error' | 'refused';\n // Identifiers and measurements only: never a payload, a name, or who a principal is.\n attributes: Record<string, string | number | boolean>;\n traceId?: string;\n spanId?: string;\n parentSpanId?: string;\n};\n\nexport type Telemetry = {\n emit: (span: TelemetrySpan) => void;\n};\n\nexport type Emit = (span: TelemetrySpan) => void;\n\nexport const emitterOf = (telemetry: Telemetry | undefined): Emit | undefined =>\n telemetry === undefined\n ? undefined\n : (span) => {\n try {\n telemetry.emit(span);\n } catch (err) {\n console.error('[moss:telemetry]', err);\n }\n };\n\nexport type SpanClock = { startUnixNano: number; endUnixNano: () => number };\n\nconst elapsedClock = (): number => (typeof performance !== 'undefined' ? performance.now() : Date.now());\n\nexport const spanClock = (): SpanClock => {\n const startUnixNano = Date.now() * 1e6;\n const t0 = elapsedClock();\n return { startUnixNano, endUnixNano: () => startUnixNano + (elapsedClock() - t0) * 1e6 };\n};\n\nconst stamp = { origin: z.string() };\n\nexport const FabricMessageSchema = z.discriminatedUnion('kind', [\n z.strictObject({ kind: z.literal('invalidate-identity'), principal: z.string(), ...stamp }),\n z.strictObject({ kind: z.literal('invalidate-tag'), tag: z.string(), ...stamp }),\n z.strictObject({ kind: z.literal('nudge'), principal: z.string(), channel: z.string(), ...stamp }),\n]);\n\nexport type FabricMessage = z.infer<typeof FabricMessageSchema>;\n\ntype Unstamped<Message> = Message extends unknown ? Omit<Message, 'origin'> : never;\nexport type FabricSignal = Unstamped<FabricMessage>;\n\nexport type Fabric = {\n publish: (message: FabricMessage) => void;\n subscribe: (apply: (message: unknown) => void) => void;\n};\n"]}
@@ -1,169 +0,0 @@
1
- import { Hono } from 'hono';
2
- import { VerifyReport } from '@niscorp/charter';
3
- import { Shell, RenderNode, ActionDefinition } from '@niscorp/nova';
4
- import { ScopePolicy } from '@niscorp/vex';
5
- import { S as SocketAccept } from './socket-D90h1xSV.cjs';
6
- import { ScreenHead } from '@niscorp/nova/document';
7
-
8
- type IdentityReport = {
9
- principal: string;
10
- since: number;
11
- lastSeen: number;
12
- };
13
- type IdentityRecord = {
14
- roles: readonly string[];
15
- scope: Record<string, unknown>;
16
- installed?: readonly string[];
17
- tag?: string;
18
- };
19
-
20
- type ResolvedIdentity = {
21
- roles: readonly string[];
22
- scope: Record<string, unknown>;
23
- installed: readonly string[] | undefined;
24
- memoKey: string;
25
- record?: IdentityRecord;
26
- };
27
-
28
- type Catalog = {
29
- ids: readonly string[];
30
- hash: string;
31
- };
32
-
33
- type ExecuteAs = (role: string, fingerprint: string, context: Record<string, unknown>, scope?: Record<string, unknown>) => Promise<unknown>;
34
-
35
- type ShellConnection = {
36
- send: (text: string) => void;
37
- close: (code?: number, reason?: string) => void;
38
- seal?: (token: string) => Promise<string>;
39
- };
40
- type ShellSession = {
41
- readonly shell: Shell;
42
- attach: (connection: ShellConnection, options?: {
43
- delta?: boolean;
44
- }) => void;
45
- detach: (connection: ShellConnection) => void;
46
- resync: (connection: ShellConnection) => void;
47
- dispatch: (canvas: string, event: Record<string, unknown>) => void;
48
- publish: (channel: string, payload?: unknown) => void;
49
- back: () => boolean;
50
- popTo: (canvas: string, instance: string) => void;
51
- reset: () => void;
52
- };
53
- type ShellReport = {
54
- principal: string;
55
- connections: number;
56
- since: number;
57
- idleSince: number | null;
58
- canvases: {
59
- id: string;
60
- actions: readonly string[];
61
- }[];
62
- };
63
- type ShellSnapshot = {
64
- frame: RenderNode[];
65
- trees: Record<string, RenderNode[]>;
66
- seed?: string;
67
- settled: boolean;
68
- live: boolean;
69
- why: string[];
70
- drawnWith: string[];
71
- };
72
- type ShellOpening = {
73
- seed?: string;
74
- inputs?: Record<string, Record<string, unknown>>;
75
- };
76
- type ShellHost = {
77
- session: (token: string | null, principal: string | null, options?: ShellOpening) => Promise<ShellSession>;
78
- snapshot: (token: string | null, principal: string | null, options?: {
79
- waitMs?: number;
80
- inputs?: ShellOpening['inputs'];
81
- }) => Promise<ShellSnapshot>;
82
- deliver: (principal: string, channel: string, payload?: unknown) => boolean;
83
- list: () => ShellReport[];
84
- reset: (principal: string) => boolean;
85
- };
86
-
87
- type Env = {
88
- Variables: {
89
- principal: string | null;
90
- resolved: ResolvedIdentity;
91
- };
92
- };
93
- type MossServer = Hono<Env> & {
94
- socket: SocketAccept;
95
- shells?: ShellHost;
96
- principalOf: (token: string) => Promise<string | null>;
97
- page: (path: string) => {
98
- name: string;
99
- host: ShellHost;
100
- inputs: Record<string, Record<string, unknown>>;
101
- } | undefined;
102
- pages: readonly {
103
- name: string;
104
- path: string;
105
- }[];
106
- refresh: () => void;
107
- replaceActions: (source: string, actions: Record<string, ActionDefinition>) => void;
108
- actions: () => Readonly<Record<string, ActionDefinition>>;
109
- catalogOf: (principal: string | null) => Promise<Catalog>;
110
- policyForRoles: (roles: readonly string[]) => ScopePolicy;
111
- charterReport: () => VerifyReport;
112
- invalidateIdentity: (principal: string) => boolean;
113
- identity: (principal: string | null) => Promise<IdentityRecord>;
114
- executeAs: ExecuteAs;
115
- invalidateTag: (tag: string) => number;
116
- nudge: (principal: string, channel: string) => void;
117
- close: () => void;
118
- identities?: {
119
- list: () => IdentityReport[];
120
- meter: () => {
121
- size: number;
122
- max: number;
123
- resolved: number;
124
- evicted: number;
125
- expired: number;
126
- };
127
- };
128
- };
129
-
130
- type DocumentHost = Pick<ShellHost, 'snapshot'>;
131
- type DocumentSource = {
132
- principalOf: (token: string) => Promise<string | null>;
133
- page: (path: string) => {
134
- name: string;
135
- host: DocumentHost;
136
- inputs: Record<string, Record<string, unknown>>;
137
- } | undefined;
138
- shells?: DocumentHost;
139
- };
140
- type DocumentConfig = {
141
- server: DocumentSource;
142
- template: string;
143
- request: {
144
- path: string;
145
- cookie?: string | null;
146
- host?: string | null;
147
- };
148
- draw: (snapshot: ShellSnapshot) => string | Promise<string>;
149
- htmlAttributes?: (snapshot: ShellSnapshot) => Record<string, string>;
150
- site?: string;
151
- tokenKey?: string;
152
- waitMs?: number;
153
- root?: string;
154
- };
155
- type DrawnDocument = {
156
- html: string;
157
- headers: Record<string, string>;
158
- drawn: boolean;
159
- principal: string | null;
160
- page?: string;
161
- head?: ScreenHead;
162
- live?: boolean;
163
- why?: string[];
164
- drawnWith?: string[];
165
- settled?: boolean;
166
- };
167
- declare const renderDocument: (config: DocumentConfig) => Promise<DrawnDocument>;
168
-
169
- export { type DocumentConfig as D, type ExecuteAs as E, type IdentityRecord as I, type MossServer as M, type ShellHost as S, type DrawnDocument as a, type ShellSnapshot as b, renderDocument as r };
@@ -1,169 +0,0 @@
1
- import { Hono } from 'hono';
2
- import { VerifyReport } from '@niscorp/charter';
3
- import { Shell, RenderNode, ActionDefinition } from '@niscorp/nova';
4
- import { ScopePolicy } from '@niscorp/vex';
5
- import { S as SocketAccept } from './socket-D90h1xSV.js';
6
- import { ScreenHead } from '@niscorp/nova/document';
7
-
8
- type IdentityReport = {
9
- principal: string;
10
- since: number;
11
- lastSeen: number;
12
- };
13
- type IdentityRecord = {
14
- roles: readonly string[];
15
- scope: Record<string, unknown>;
16
- installed?: readonly string[];
17
- tag?: string;
18
- };
19
-
20
- type ResolvedIdentity = {
21
- roles: readonly string[];
22
- scope: Record<string, unknown>;
23
- installed: readonly string[] | undefined;
24
- memoKey: string;
25
- record?: IdentityRecord;
26
- };
27
-
28
- type Catalog = {
29
- ids: readonly string[];
30
- hash: string;
31
- };
32
-
33
- type ExecuteAs = (role: string, fingerprint: string, context: Record<string, unknown>, scope?: Record<string, unknown>) => Promise<unknown>;
34
-
35
- type ShellConnection = {
36
- send: (text: string) => void;
37
- close: (code?: number, reason?: string) => void;
38
- seal?: (token: string) => Promise<string>;
39
- };
40
- type ShellSession = {
41
- readonly shell: Shell;
42
- attach: (connection: ShellConnection, options?: {
43
- delta?: boolean;
44
- }) => void;
45
- detach: (connection: ShellConnection) => void;
46
- resync: (connection: ShellConnection) => void;
47
- dispatch: (canvas: string, event: Record<string, unknown>) => void;
48
- publish: (channel: string, payload?: unknown) => void;
49
- back: () => boolean;
50
- popTo: (canvas: string, instance: string) => void;
51
- reset: () => void;
52
- };
53
- type ShellReport = {
54
- principal: string;
55
- connections: number;
56
- since: number;
57
- idleSince: number | null;
58
- canvases: {
59
- id: string;
60
- actions: readonly string[];
61
- }[];
62
- };
63
- type ShellSnapshot = {
64
- frame: RenderNode[];
65
- trees: Record<string, RenderNode[]>;
66
- seed?: string;
67
- settled: boolean;
68
- live: boolean;
69
- why: string[];
70
- drawnWith: string[];
71
- };
72
- type ShellOpening = {
73
- seed?: string;
74
- inputs?: Record<string, Record<string, unknown>>;
75
- };
76
- type ShellHost = {
77
- session: (token: string | null, principal: string | null, options?: ShellOpening) => Promise<ShellSession>;
78
- snapshot: (token: string | null, principal: string | null, options?: {
79
- waitMs?: number;
80
- inputs?: ShellOpening['inputs'];
81
- }) => Promise<ShellSnapshot>;
82
- deliver: (principal: string, channel: string, payload?: unknown) => boolean;
83
- list: () => ShellReport[];
84
- reset: (principal: string) => boolean;
85
- };
86
-
87
- type Env = {
88
- Variables: {
89
- principal: string | null;
90
- resolved: ResolvedIdentity;
91
- };
92
- };
93
- type MossServer = Hono<Env> & {
94
- socket: SocketAccept;
95
- shells?: ShellHost;
96
- principalOf: (token: string) => Promise<string | null>;
97
- page: (path: string) => {
98
- name: string;
99
- host: ShellHost;
100
- inputs: Record<string, Record<string, unknown>>;
101
- } | undefined;
102
- pages: readonly {
103
- name: string;
104
- path: string;
105
- }[];
106
- refresh: () => void;
107
- replaceActions: (source: string, actions: Record<string, ActionDefinition>) => void;
108
- actions: () => Readonly<Record<string, ActionDefinition>>;
109
- catalogOf: (principal: string | null) => Promise<Catalog>;
110
- policyForRoles: (roles: readonly string[]) => ScopePolicy;
111
- charterReport: () => VerifyReport;
112
- invalidateIdentity: (principal: string) => boolean;
113
- identity: (principal: string | null) => Promise<IdentityRecord>;
114
- executeAs: ExecuteAs;
115
- invalidateTag: (tag: string) => number;
116
- nudge: (principal: string, channel: string) => void;
117
- close: () => void;
118
- identities?: {
119
- list: () => IdentityReport[];
120
- meter: () => {
121
- size: number;
122
- max: number;
123
- resolved: number;
124
- evicted: number;
125
- expired: number;
126
- };
127
- };
128
- };
129
-
130
- type DocumentHost = Pick<ShellHost, 'snapshot'>;
131
- type DocumentSource = {
132
- principalOf: (token: string) => Promise<string | null>;
133
- page: (path: string) => {
134
- name: string;
135
- host: DocumentHost;
136
- inputs: Record<string, Record<string, unknown>>;
137
- } | undefined;
138
- shells?: DocumentHost;
139
- };
140
- type DocumentConfig = {
141
- server: DocumentSource;
142
- template: string;
143
- request: {
144
- path: string;
145
- cookie?: string | null;
146
- host?: string | null;
147
- };
148
- draw: (snapshot: ShellSnapshot) => string | Promise<string>;
149
- htmlAttributes?: (snapshot: ShellSnapshot) => Record<string, string>;
150
- site?: string;
151
- tokenKey?: string;
152
- waitMs?: number;
153
- root?: string;
154
- };
155
- type DrawnDocument = {
156
- html: string;
157
- headers: Record<string, string>;
158
- drawn: boolean;
159
- principal: string | null;
160
- page?: string;
161
- head?: ScreenHead;
162
- live?: boolean;
163
- why?: string[];
164
- drawnWith?: string[];
165
- settled?: boolean;
166
- };
167
- declare const renderDocument: (config: DocumentConfig) => Promise<DrawnDocument>;
168
-
169
- export { type DocumentConfig as D, type ExecuteAs as E, type IdentityRecord as I, type MossServer as M, type ShellHost as S, type DrawnDocument as a, type ShellSnapshot as b, renderDocument as r };