@niscorp/moss 0.3.2 → 0.3.3

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 (48) hide show
  1. package/CHANGELOG.md +102 -0
  2. package/DESIGN.md +84 -19
  3. package/DOCS.md +170 -35
  4. package/README.md +2 -2
  5. package/dist/{chunk-J72N3EMJ.js → chunk-4T6KAXBP.js} +45 -27
  6. package/dist/chunk-4T6KAXBP.js.map +1 -0
  7. package/dist/{chunk-ZP3C53AC.js → chunk-AUZMT3GL.js} +739 -654
  8. package/dist/chunk-AUZMT3GL.js.map +1 -0
  9. package/dist/{chunk-ZOEUEMDX.js → chunk-HOZID4EM.js} +131 -16
  10. package/dist/chunk-HOZID4EM.js.map +1 -0
  11. package/dist/chunk-NE2EXMTO.js +103 -0
  12. package/dist/chunk-NE2EXMTO.js.map +1 -0
  13. package/dist/client/node.cjs +1 -1
  14. package/dist/client/node.cjs.map +1 -1
  15. package/dist/client/node.js +1 -1
  16. package/dist/client/node.js.map +1 -1
  17. package/dist/client.cjs +60 -26
  18. package/dist/client.cjs.map +1 -1
  19. package/dist/client.d.cts +6 -1
  20. package/dist/client.d.ts +6 -1
  21. package/dist/client.js +2 -2
  22. package/dist/{document-D9khv9jI.d.cts → document-DhWxieUc.d.cts} +22 -3
  23. package/dist/{document-D9khv9jI.d.ts → document-DhWxieUc.d.ts} +22 -3
  24. package/dist/index.cjs +777 -572
  25. package/dist/index.cjs.map +1 -1
  26. package/dist/index.d.cts +19 -3
  27. package/dist/index.d.ts +19 -3
  28. package/dist/index.js +2 -2
  29. package/dist/node.cjs +370 -219
  30. package/dist/node.cjs.map +1 -1
  31. package/dist/node.d.cts +2 -1
  32. package/dist/node.d.ts +2 -1
  33. package/dist/node.js +3 -3
  34. package/dist/terminal/index.cjs +60 -26
  35. package/dist/terminal/index.cjs.map +1 -1
  36. package/dist/terminal/index.js +2 -2
  37. package/dist/vite.cjs +103 -28
  38. package/dist/vite.cjs.map +1 -1
  39. package/dist/vite.d.cts +1 -1
  40. package/dist/vite.d.ts +1 -1
  41. package/dist/vite.js +14 -9
  42. package/dist/vite.js.map +1 -1
  43. package/package.json +9 -9
  44. package/dist/chunk-J72N3EMJ.js.map +0 -1
  45. package/dist/chunk-SUVDISEG.js +0 -64
  46. package/dist/chunk-SUVDISEG.js.map +0 -1
  47. package/dist/chunk-ZOEUEMDX.js.map +0 -1
  48. package/dist/chunk-ZP3C53AC.js.map +0 -1
@@ -1,7 +1,7 @@
1
1
  import { ScreenHead } from '@niscorp/nova/document';
2
2
  import * as _niscorp_nova from '@niscorp/nova';
3
3
  import { LayoutPaletteEntry, ActionDefinition, Shell, FetchFn, LayoutNode, CanvasConfig, ActionFragment, FunctionHandler, RenderNode } from '@niscorp/nova';
4
- import { PgPool, MutationClient, CacheBackend, ScopePolicy, ScopeBehaviors, SeedEntry, SeedMutation } from '@niscorp/vex';
4
+ import { PgPool, MutationClient, CacheBackend, QueryEngineConfig, ScopePolicy, ScopeBehaviors, SeedEntry, SeedMutation } from '@niscorp/vex';
5
5
  import * as _niscorp_tide from '@niscorp/tide';
6
6
  import { Upgrader, Sequence } from '@niscorp/strata';
7
7
  import { z } from 'zod';
@@ -517,8 +517,11 @@ type NiscRuntime = {
517
517
  pool: PgPool;
518
518
  db: MutationClient;
519
519
  cache?: CacheBackend;
520
+ vexConfig?: QueryEngineConfig['config'];
520
521
  session: SessionVerifier | 'sessions' | 'dev-open';
522
+ origins?: readonly string[];
521
523
  migrations?: 'apply' | 'verify';
524
+ tables?: readonly Sequence[];
522
525
  shellIdleMs?: number;
523
526
  endpointTimeoutMs?: number;
524
527
  sessionRevalidateMs?: number;
@@ -833,6 +836,14 @@ type Connection = {
833
836
  close: (code?: number, reason?: string) => void;
834
837
  onMessage: (fn: (text: string) => void) => void;
835
838
  onClose: (fn: () => void) => void;
839
+ upgrade?: {
840
+ offered: readonly string[];
841
+ origin?: string | null;
842
+ host?: string | null;
843
+ cookie?: string | null;
844
+ answer?: (cookies: readonly string[]) => void;
845
+ };
846
+ seal?: (token: string) => Promise<string>;
836
847
  };
837
848
  type ServerMessage = {
838
849
  type: 'hello';
@@ -861,6 +872,9 @@ type ServerMessage = {
861
872
  } | {
862
873
  type: 'session';
863
874
  token: string;
875
+ } | {
876
+ type: 'session';
877
+ sealed: string;
864
878
  } | {
865
879
  type: 'error';
866
880
  code: string;
@@ -886,6 +900,8 @@ type ClientMessage = {
886
900
  } | {
887
901
  type: 'reset';
888
902
  };
903
+ declare const PROTOCOL = 2;
904
+ declare const offerToken: (token: string | null, sealed?: string | null) => string[];
889
905
  declare const CLOSE_INVALID_TOKEN = 4401;
890
906
  declare const CLOSE_SIGNED_OUT = 4403;
891
907
  declare const CLOSE_SHELL_FAILED = 4500;
@@ -899,6 +915,8 @@ type SocketContext = {
899
915
  } | undefined;
900
916
  revalidateMs?: number;
901
917
  telemetry?: Telemetry;
918
+ origins?: readonly string[];
919
+ sessionLastsMs?: (token: string) => number | null | Promise<number | null>;
902
920
  };
903
921
  declare const DEFAULT_REVALIDATE_MS: number;
904
922
  type SocketAccept = ((url: string, connection: Connection) => Promise<void>) & {
@@ -957,7 +975,7 @@ type MossServer = Hono<Env> & {
957
975
  declare const createServer: (app: NiscApp, runtime: NiscRuntime) => Promise<MossServer>;
958
976
 
959
977
  declare const SNAPSHOT_ELEMENT_ID = "nisc-snapshot";
960
- declare const tokenFromCookie: (header: string | null | undefined, tokenKey?: string) => string | null;
978
+
961
979
  declare const embedSnapshot: (snapshot: ShellSnapshot, principal: string | null, path?: string) => string;
962
980
  declare const documentHeaders: (principal: string | null) => Record<string, string>;
963
981
  type DocumentConfig = {
@@ -966,6 +984,7 @@ type DocumentConfig = {
966
984
  request: {
967
985
  path: string;
968
986
  cookie?: string | null;
987
+ host?: string | null;
969
988
  };
970
989
  draw: (snapshot: ShellSnapshot) => string | Promise<string>;
971
990
  htmlAttributes?: (snapshot: ShellSnapshot) => Record<string, string>;
@@ -1002,4 +1021,4 @@ declare const exportDocuments: (config: Omit<DocumentConfig, "request"> & {
1002
1021
  paths: readonly string[];
1003
1022
  }) => Promise<ExportedDocument[]>;
1004
1023
 
1005
- export { type SpanClock as $, type NiscApp as A, type Bundle as B, CLOSE_INVALID_TOKEN as C, DEFAULT_IDENTITY_IDLE_MS as D, type Emit as E, type Fabric as F, type PressResult as G, type RunSink as H, type IdentityCache as I, type RunTurn as J, SNAPSHOT_ELEMENT_ID as K, type LayoutVariant as L, MOSS_SEQUENCE as M, type NiscRuntime as N, type ServerMessage as O, type PageManifest as P, type ShellHost as Q, type RunRecord as R, type SessionVerifier as S, type ShellManifest as T, type ShellNeed as U, type ShellOpening as V, type ShellReport as W, type ShellSession as X, type ShellSnapshot as Y, type SocketAccept as Z, type SocketContext as _, CLOSE_SHELL_FAILED as a, type StorePress as a0, type Telemetry as a1, type TelemetrySpan as a2, buildContract as a3, callIntegrationWith as a4, contractAsMarkdown as a5, copyPress as a6, createIdentityCache as a7, createServer as a8, createShellHost as a9, resolveVariantsForRoles as aA, runIntake as aB, shellNeedOf as aC, spanClock as aD, tokenFromCookie as aE, verifyVariants as aF, wearableOf as aG, wireFabric as aH, createSocket as aa, defineApp as ab, describePlacements as ac, devSession as ad, documentHeaders as ae, embedSnapshot as af, emitterOf as ag, exportDocuments as ah, filterInstalled as ai, initIntegrations as aj, integrationByKey as ak, integrationOfAction as al, listAttachments as am, listIntegrations as an, listPlacements as ao, loadIntegrationActions as ap, memoKeyOf as aq, mintDevToken as ar, renderDocument as as, resolveCatalog as at, resolveCatalogForRoles as au, resolvePolicy as av, resolvePolicyAtReach as aw, resolvePolicyForRoles as ax, resolveRoles as ay, resolveVariants as az, CLOSE_SIGNED_OUT as b, type CallIntegration as c, type Catalog as d, type ClientMessage as e, type Connection as f, type Contract as g, DEFAULT_IDENTITY_MAX as h, DEFAULT_IDLE_MS as i, DEFAULT_REVALIDATE_MS as j, type DocumentConfig as k, type DrawnDocument as l, type ExecuteAs as m, type ExportedDocument as n, type FabricApply as o, type FabricMessage as p, type FabricSignal as q, type FactIntake as r, type FunctionSession as s, type IdentityCacheContext as t, type IdentityRecord as u, type IdentityReport as v, type IntakeContext as w, type IntakeResult as x, type IntegrationRow as y, type MossServer as z };
1024
+ export { type SocketContext as $, type MossServer as A, type Bundle as B, CLOSE_INVALID_TOKEN as C, DEFAULT_IDENTITY_IDLE_MS as D, type Emit as E, type Fabric as F, PROTOCOL as G, type PressResult as H, type IdentityCache as I, type RunSink as J, type RunTurn as K, type LayoutVariant as L, MOSS_SEQUENCE as M, type NiscRuntime as N, SNAPSHOT_ELEMENT_ID as O, type PageManifest as P, type ServerMessage as Q, type RunRecord as R, type SessionVerifier as S, type ShellHost as T, type ShellManifest as U, type ShellNeed as V, type ShellOpening as W, type ShellReport as X, type ShellSession as Y, type ShellSnapshot as Z, type SocketAccept as _, type NiscApp as a, type SpanClock as a0, type StorePress as a1, type Telemetry as a2, type TelemetrySpan as a3, buildContract as a4, callIntegrationWith as a5, contractAsMarkdown as a6, copyPress as a7, createIdentityCache as a8, createServer as a9, resolveRoles as aA, resolveVariants as aB, resolveVariantsForRoles as aC, runIntake as aD, shellNeedOf as aE, spanClock as aF, verifyVariants as aG, wearableOf as aH, wireFabric as aI, createShellHost as aa, createSocket as ab, defineApp as ac, describePlacements as ad, devSession as ae, documentHeaders as af, embedSnapshot as ag, emitterOf as ah, exportDocuments as ai, filterInstalled as aj, initIntegrations as ak, integrationByKey as al, integrationOfAction as am, listAttachments as an, listIntegrations as ao, listPlacements as ap, loadIntegrationActions as aq, memoKeyOf as ar, mintDevToken as as, offerToken as at, renderDocument as au, resolveCatalog as av, resolveCatalogForRoles as aw, resolvePolicy as ax, resolvePolicyAtReach as ay, resolvePolicyForRoles as az, CLOSE_SHELL_FAILED as b, CLOSE_SIGNED_OUT as c, type CallIntegration as d, type Catalog as e, type ClientMessage as f, type Connection as g, type Contract as h, DEFAULT_IDENTITY_MAX as i, DEFAULT_IDLE_MS as j, DEFAULT_REVALIDATE_MS as k, type DocumentConfig as l, type DrawnDocument as m, type ExecuteAs as n, type ExportedDocument as o, type FabricApply as p, type FabricMessage as q, type FabricSignal as r, type FactIntake as s, type FunctionSession as t, type IdentityCacheContext as u, type IdentityRecord as v, type IdentityReport as w, type IntakeContext as x, type IntakeResult as y, type IntegrationRow as z };
@@ -1,7 +1,7 @@
1
1
  import { ScreenHead } from '@niscorp/nova/document';
2
2
  import * as _niscorp_nova from '@niscorp/nova';
3
3
  import { LayoutPaletteEntry, ActionDefinition, Shell, FetchFn, LayoutNode, CanvasConfig, ActionFragment, FunctionHandler, RenderNode } from '@niscorp/nova';
4
- import { PgPool, MutationClient, CacheBackend, ScopePolicy, ScopeBehaviors, SeedEntry, SeedMutation } from '@niscorp/vex';
4
+ import { PgPool, MutationClient, CacheBackend, QueryEngineConfig, ScopePolicy, ScopeBehaviors, SeedEntry, SeedMutation } from '@niscorp/vex';
5
5
  import * as _niscorp_tide from '@niscorp/tide';
6
6
  import { Upgrader, Sequence } from '@niscorp/strata';
7
7
  import { z } from 'zod';
@@ -517,8 +517,11 @@ type NiscRuntime = {
517
517
  pool: PgPool;
518
518
  db: MutationClient;
519
519
  cache?: CacheBackend;
520
+ vexConfig?: QueryEngineConfig['config'];
520
521
  session: SessionVerifier | 'sessions' | 'dev-open';
522
+ origins?: readonly string[];
521
523
  migrations?: 'apply' | 'verify';
524
+ tables?: readonly Sequence[];
522
525
  shellIdleMs?: number;
523
526
  endpointTimeoutMs?: number;
524
527
  sessionRevalidateMs?: number;
@@ -833,6 +836,14 @@ type Connection = {
833
836
  close: (code?: number, reason?: string) => void;
834
837
  onMessage: (fn: (text: string) => void) => void;
835
838
  onClose: (fn: () => void) => void;
839
+ upgrade?: {
840
+ offered: readonly string[];
841
+ origin?: string | null;
842
+ host?: string | null;
843
+ cookie?: string | null;
844
+ answer?: (cookies: readonly string[]) => void;
845
+ };
846
+ seal?: (token: string) => Promise<string>;
836
847
  };
837
848
  type ServerMessage = {
838
849
  type: 'hello';
@@ -861,6 +872,9 @@ type ServerMessage = {
861
872
  } | {
862
873
  type: 'session';
863
874
  token: string;
875
+ } | {
876
+ type: 'session';
877
+ sealed: string;
864
878
  } | {
865
879
  type: 'error';
866
880
  code: string;
@@ -886,6 +900,8 @@ type ClientMessage = {
886
900
  } | {
887
901
  type: 'reset';
888
902
  };
903
+ declare const PROTOCOL = 2;
904
+ declare const offerToken: (token: string | null, sealed?: string | null) => string[];
889
905
  declare const CLOSE_INVALID_TOKEN = 4401;
890
906
  declare const CLOSE_SIGNED_OUT = 4403;
891
907
  declare const CLOSE_SHELL_FAILED = 4500;
@@ -899,6 +915,8 @@ type SocketContext = {
899
915
  } | undefined;
900
916
  revalidateMs?: number;
901
917
  telemetry?: Telemetry;
918
+ origins?: readonly string[];
919
+ sessionLastsMs?: (token: string) => number | null | Promise<number | null>;
902
920
  };
903
921
  declare const DEFAULT_REVALIDATE_MS: number;
904
922
  type SocketAccept = ((url: string, connection: Connection) => Promise<void>) & {
@@ -957,7 +975,7 @@ type MossServer = Hono<Env> & {
957
975
  declare const createServer: (app: NiscApp, runtime: NiscRuntime) => Promise<MossServer>;
958
976
 
959
977
  declare const SNAPSHOT_ELEMENT_ID = "nisc-snapshot";
960
- declare const tokenFromCookie: (header: string | null | undefined, tokenKey?: string) => string | null;
978
+
961
979
  declare const embedSnapshot: (snapshot: ShellSnapshot, principal: string | null, path?: string) => string;
962
980
  declare const documentHeaders: (principal: string | null) => Record<string, string>;
963
981
  type DocumentConfig = {
@@ -966,6 +984,7 @@ type DocumentConfig = {
966
984
  request: {
967
985
  path: string;
968
986
  cookie?: string | null;
987
+ host?: string | null;
969
988
  };
970
989
  draw: (snapshot: ShellSnapshot) => string | Promise<string>;
971
990
  htmlAttributes?: (snapshot: ShellSnapshot) => Record<string, string>;
@@ -1002,4 +1021,4 @@ declare const exportDocuments: (config: Omit<DocumentConfig, "request"> & {
1002
1021
  paths: readonly string[];
1003
1022
  }) => Promise<ExportedDocument[]>;
1004
1023
 
1005
- export { type SpanClock as $, type NiscApp as A, type Bundle as B, CLOSE_INVALID_TOKEN as C, DEFAULT_IDENTITY_IDLE_MS as D, type Emit as E, type Fabric as F, type PressResult as G, type RunSink as H, type IdentityCache as I, type RunTurn as J, SNAPSHOT_ELEMENT_ID as K, type LayoutVariant as L, MOSS_SEQUENCE as M, type NiscRuntime as N, type ServerMessage as O, type PageManifest as P, type ShellHost as Q, type RunRecord as R, type SessionVerifier as S, type ShellManifest as T, type ShellNeed as U, type ShellOpening as V, type ShellReport as W, type ShellSession as X, type ShellSnapshot as Y, type SocketAccept as Z, type SocketContext as _, CLOSE_SHELL_FAILED as a, type StorePress as a0, type Telemetry as a1, type TelemetrySpan as a2, buildContract as a3, callIntegrationWith as a4, contractAsMarkdown as a5, copyPress as a6, createIdentityCache as a7, createServer as a8, createShellHost as a9, resolveVariantsForRoles as aA, runIntake as aB, shellNeedOf as aC, spanClock as aD, tokenFromCookie as aE, verifyVariants as aF, wearableOf as aG, wireFabric as aH, createSocket as aa, defineApp as ab, describePlacements as ac, devSession as ad, documentHeaders as ae, embedSnapshot as af, emitterOf as ag, exportDocuments as ah, filterInstalled as ai, initIntegrations as aj, integrationByKey as ak, integrationOfAction as al, listAttachments as am, listIntegrations as an, listPlacements as ao, loadIntegrationActions as ap, memoKeyOf as aq, mintDevToken as ar, renderDocument as as, resolveCatalog as at, resolveCatalogForRoles as au, resolvePolicy as av, resolvePolicyAtReach as aw, resolvePolicyForRoles as ax, resolveRoles as ay, resolveVariants as az, CLOSE_SIGNED_OUT as b, type CallIntegration as c, type Catalog as d, type ClientMessage as e, type Connection as f, type Contract as g, DEFAULT_IDENTITY_MAX as h, DEFAULT_IDLE_MS as i, DEFAULT_REVALIDATE_MS as j, type DocumentConfig as k, type DrawnDocument as l, type ExecuteAs as m, type ExportedDocument as n, type FabricApply as o, type FabricMessage as p, type FabricSignal as q, type FactIntake as r, type FunctionSession as s, type IdentityCacheContext as t, type IdentityRecord as u, type IdentityReport as v, type IntakeContext as w, type IntakeResult as x, type IntegrationRow as y, type MossServer as z };
1024
+ export { type SocketContext as $, type MossServer as A, type Bundle as B, CLOSE_INVALID_TOKEN as C, DEFAULT_IDENTITY_IDLE_MS as D, type Emit as E, type Fabric as F, PROTOCOL as G, type PressResult as H, type IdentityCache as I, type RunSink as J, type RunTurn as K, type LayoutVariant as L, MOSS_SEQUENCE as M, type NiscRuntime as N, SNAPSHOT_ELEMENT_ID as O, type PageManifest as P, type ServerMessage as Q, type RunRecord as R, type SessionVerifier as S, type ShellHost as T, type ShellManifest as U, type ShellNeed as V, type ShellOpening as W, type ShellReport as X, type ShellSession as Y, type ShellSnapshot as Z, type SocketAccept as _, type NiscApp as a, type SpanClock as a0, type StorePress as a1, type Telemetry as a2, type TelemetrySpan as a3, buildContract as a4, callIntegrationWith as a5, contractAsMarkdown as a6, copyPress as a7, createIdentityCache as a8, createServer as a9, resolveRoles as aA, resolveVariants as aB, resolveVariantsForRoles as aC, runIntake as aD, shellNeedOf as aE, spanClock as aF, verifyVariants as aG, wearableOf as aH, wireFabric as aI, createShellHost as aa, createSocket as ab, defineApp as ac, describePlacements as ad, devSession as ae, documentHeaders as af, embedSnapshot as ag, emitterOf as ah, exportDocuments as ai, filterInstalled as aj, initIntegrations as ak, integrationByKey as al, integrationOfAction as am, listAttachments as an, listIntegrations as ao, listPlacements as ap, loadIntegrationActions as aq, memoKeyOf as ar, mintDevToken as as, offerToken as at, renderDocument as au, resolveCatalog as av, resolveCatalogForRoles as aw, resolvePolicy as ax, resolvePolicyAtReach as ay, resolvePolicyForRoles as az, CLOSE_SHELL_FAILED as b, CLOSE_SIGNED_OUT as c, type CallIntegration as d, type Catalog as e, type ClientMessage as f, type Connection as g, type Contract as h, DEFAULT_IDENTITY_MAX as i, DEFAULT_IDLE_MS as j, DEFAULT_REVALIDATE_MS as k, type DocumentConfig as l, type DrawnDocument as m, type ExecuteAs as n, type ExportedDocument as o, type FabricApply as p, type FabricMessage as q, type FabricSignal as r, type FactIntake as s, type FunctionSession as t, type IdentityCacheContext as u, type IdentityRecord as v, type IdentityReport as w, type IntakeContext as x, type IntakeResult as y, type IntegrationRow as z };