@docstack/client 0.1.5 → 0.1.8
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 +10 -0
- package/README.md +1 -1
- package/lib/core/attribute.d.ts +11 -2
- package/lib/core/class.d.ts +29 -6
- package/lib/core/content-transfer.d.ts +178 -0
- package/lib/core/crypto-engine/index.d.ts +82 -1
- package/lib/core/crypto-engine/utils.d.ts +36 -1
- package/lib/core/datamodel/index.d.ts +16 -0
- package/lib/core/domain.d.ts +1 -1
- package/lib/core/guarded-db.d.ts +53 -0
- package/lib/core/index.d.ts +138 -2
- package/lib/core/job-engine/schedule.d.ts +90 -0
- package/lib/core/job-engine/scheduler.d.ts +206 -0
- package/lib/core/policy-engine/index.d.ts +35 -0
- package/lib/core/query-engine/classes.d.ts +24 -0
- package/lib/core/query-engine/executor.d.ts +11 -0
- package/lib/core/query-engine/index.d.ts +2 -1
- package/lib/core/query-engine/planner.d.ts +19 -0
- package/lib/core/stack.d.ts +690 -7
- package/lib/core/sync/class-filter.d.ts +106 -0
- package/lib/core/sync/filter-identity.d.ts +53 -0
- package/lib/core/sync/index.d.ts +352 -0
- package/lib/core/sync/internal-docs.d.ts +159 -0
- package/lib/core/sync/tenants.d.ts +67 -0
- package/lib/index.d.ts +38 -1
- package/lib/index.js +5865 -664
- package/lib/index.umd.js +5903 -681
- package/lib/plugins/pouchdb.d.ts +43 -3
- package/lib/utils/logger/index.d.ts +28 -4
- package/lib/utils/logger/transport.d.ts +52 -11
- package/package.json +18 -10
- package/lib/core/attribute.js +0 -406
- package/lib/core/attribute.js.map +0 -1
- package/lib/core/class.js +0 -774
- package/lib/core/class.js.map +0 -1
- package/lib/core/crypto-engine/index.js +0 -229
- package/lib/core/crypto-engine/index.js.map +0 -1
- package/lib/core/crypto-engine/utils.js +0 -88
- package/lib/core/crypto-engine/utils.js.map +0 -1
- package/lib/core/datamodel/index.js +0 -1308
- package/lib/core/datamodel/index.js.map +0 -1
- package/lib/core/domain.js +0 -423
- package/lib/core/domain.js.map +0 -1
- package/lib/core/index.js +0 -532
- package/lib/core/index.js.map +0 -1
- package/lib/core/job-engine/index.js +0 -220
- package/lib/core/job-engine/index.js.map +0 -1
- package/lib/core/policy-engine/index.js +0 -232
- package/lib/core/policy-engine/index.js.map +0 -1
- package/lib/core/query-engine/accumulators.js +0 -258
- package/lib/core/query-engine/accumulators.js.map +0 -1
- package/lib/core/query-engine/evaluator.js +0 -179
- package/lib/core/query-engine/evaluator.js.map +0 -1
- package/lib/core/query-engine/executor.js +0 -405
- package/lib/core/query-engine/executor.js.map +0 -1
- package/lib/core/query-engine/index.js +0 -4
- package/lib/core/query-engine/index.js.map +0 -1
- package/lib/core/query-engine/parser.js +0 -515
- package/lib/core/query-engine/parser.js.map +0 -1
- package/lib/core/query-engine/planner.js +0 -330
- package/lib/core/query-engine/planner.js.map +0 -1
- package/lib/core/stack.js +0 -1827
- package/lib/core/stack.js.map +0 -1
- package/lib/core/test-utils/docstack.js +0 -222
- package/lib/core/test-utils/docstack.js.map +0 -1
- package/lib/core/trigger/index.js +0 -81
- package/lib/core/trigger/index.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/plugins/pouchdb.js +0 -412
- package/lib/plugins/pouchdb.js.map +0 -1
- package/lib/utils/crypto/index.js +0 -34
- package/lib/utils/crypto/index.js.map +0 -1
- package/lib/utils/index.js +0 -58
- package/lib/utils/index.js.map +0 -1
- package/lib/utils/logger/index.js +0 -20
- package/lib/utils/logger/index.js.map +0 -1
- package/lib/utils/logger/transport.js +0 -28
- package/lib/utils/logger/transport.js.map +0 -1
- package/lib/workers/dataModel.js +0 -48
- package/lib/workers/dataModel.js.map +0 -1
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { ClassModel } from "@docstack/shared";
|
|
2
|
+
import type { ClassFilterOptions } from "./class-filter.js";
|
|
3
|
+
import type ClientStack from "../stack.js";
|
|
4
|
+
/**
|
|
5
|
+
* Tenant scoping for replication channels.
|
|
6
|
+
*
|
|
7
|
+
* A tenant is a stack (ADR-0030). `Class.tenants` declares which tenant spaces a class
|
|
8
|
+
* belongs to - a static list, so partitioning and channel scopes are derivable before
|
|
9
|
+
* any data exists. This module compiles a channel's *entitlement* (the tenants it may
|
|
10
|
+
* see) into configuration the sync layer already understands: which stacks the channel
|
|
11
|
+
* is served at all, and a class filter for stacks holding a mix of declarations.
|
|
12
|
+
*
|
|
13
|
+
* The split matters (ADR-0030 §5): the *partition* is the datamodel's, but the
|
|
14
|
+
* *entitlement* is the serving side's to grant - it cannot come from the datamodel,
|
|
15
|
+
* because every application ships its own model and none is authoritative about the
|
|
16
|
+
* others' entitlements. Enforcement then rides the existing filter chain, which is a
|
|
17
|
+
* conjunction: a derived filter can only narrow what the declarations admit.
|
|
18
|
+
*
|
|
19
|
+
* The strongest grant here is the one that is not a filter at all: a stack outside the
|
|
20
|
+
* scope is simply never served, so its namespace is unreachable rather than filtered.
|
|
21
|
+
*
|
|
22
|
+
* @module
|
|
23
|
+
*/
|
|
24
|
+
/** A channel's entitlement, compiled into sync configuration. */
|
|
25
|
+
export interface TenantScope {
|
|
26
|
+
/**
|
|
27
|
+
* Stacks this entitlement is served at all. A stack not listed is withheld
|
|
28
|
+
* structurally - no replication is started against it, which is a stronger grant
|
|
29
|
+
* than any filter.
|
|
30
|
+
*/
|
|
31
|
+
stacks: string[];
|
|
32
|
+
/**
|
|
33
|
+
* Class rules per served stack, present only where the stack needs them: an
|
|
34
|
+
* `exclude` where classes declared for other tenants share an entitled stack, an
|
|
35
|
+
* `include` where a stack is served only because entitled classes live in it.
|
|
36
|
+
*/
|
|
37
|
+
classes: Record<string, ClassFilterOptions>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Normalizes a class model's tenant declaration.
|
|
41
|
+
*
|
|
42
|
+
* @param model - Any object carrying (or omitting) a `tenants` declaration.
|
|
43
|
+
* @returns The declared tenant names; empty for a tenant-neutral class.
|
|
44
|
+
*/
|
|
45
|
+
export declare const classTenants: (model: Partial<Pick<ClassModel, "tenants">> | null | undefined) => string[];
|
|
46
|
+
/**
|
|
47
|
+
* Compiles an entitlement into the stacks it reaches and the class rules it needs.
|
|
48
|
+
*
|
|
49
|
+
* A stack is served when its name is an entitled tenant - a tenant *is* a stack - or
|
|
50
|
+
* when it holds at least one class declared for an entitled tenant. Within a served
|
|
51
|
+
* stack:
|
|
52
|
+
*
|
|
53
|
+
* - classes declared for an entitled tenant travel;
|
|
54
|
+
* - tenant-neutral classes follow their stack: they travel when the stack itself is the
|
|
55
|
+
* entitled tenant, which is what keeps a datamodel with no declarations at today's
|
|
56
|
+
* behavior exactly;
|
|
57
|
+
* - classes declared only for other tenants are excluded.
|
|
58
|
+
*
|
|
59
|
+
* Resolved once per call, the way the sync layer resolves ephemeral classes when a
|
|
60
|
+
* replication starts (ADR-0028): a declaration that changes later takes effect on the
|
|
61
|
+
* next `sync()`, never silently mid-stream.
|
|
62
|
+
*
|
|
63
|
+
* @param stacks - The candidate stacks, typically every open stack.
|
|
64
|
+
* @param entitlement - The tenant names this channel may see.
|
|
65
|
+
* @returns Which stacks to serve, and per-stack class rules where needed.
|
|
66
|
+
*/
|
|
67
|
+
export declare const deriveTenantScope: (stacks: ClientStack[], entitlement: string[]) => Promise<TenantScope>;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,41 @@
|
|
|
1
1
|
import { DocStack } from "./core/index.js";
|
|
2
2
|
export { ClientStack, Class, Domain, Attribute, Trigger, DocStack } from "./core/index.js";
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Running jobs unattended.
|
|
5
|
+
*
|
|
6
|
+
* `JobEngine` executes a job when asked; `JobScheduler` decides when to ask, under the
|
|
7
|
+
* constraints a client imposes — an app that is closed most of the time, timers that
|
|
8
|
+
* freeze, several devices holding replicas of the same `~Job`, and job content that
|
|
9
|
+
* replicates and is executable. It is mounted at `stack.jobScheduler` and started by the
|
|
10
|
+
* application, which names the jobs allowed to run with nobody watching.
|
|
11
|
+
*/
|
|
12
|
+
export { JobEngine, JobScheduler, JOB_SCHEDULE_DOC_ID, parseSchedule, nextOccurrence } from "./core/index.js";
|
|
13
|
+
export type { SchedulerOptions, SchedulerHost, JobScheduleState, TickReport, SkipReason, ParsedSchedule, } from "./core/index.js";
|
|
14
|
+
/**
|
|
15
|
+
* The sync layer: lifecycle, filtering, convergence state and the schema gate.
|
|
16
|
+
*
|
|
17
|
+
* Transport-agnostic on purpose - `remote` is whatever PouchDB database the
|
|
18
|
+
* application hands over, so DocStack never learns about Google Drive, Firestore or
|
|
19
|
+
* anything else, and no consumer pays for a transport it does not use.
|
|
20
|
+
*/
|
|
21
|
+
export { StackSyncHandle, DocStackSyncHandle, SyncSchemaMismatchError, SYNC_META_DOC_ID, readRemoteSchemaVersion, publishSchemaVersion, createReplicationFilter, isInternalDoc, resolveInternalClasses, createClassFilter, hasClassRules, DATA_MODEL_CLASSES, withFilterIdentity, describeFilter, INTERNAL_DOC_IDS, INTERNAL_DOC_ID_PREFIXES, INTERNAL_DOC_CLASSES, OPTIONAL_INTERNAL_DOC_CLASSES, StackWriteGuardError, StackLockedError, deriveKeyId, isEncryptedPayload, deriveTenantScope, classTenants, } from "./core/index.js";
|
|
22
|
+
export { SYSTEM_SEEDED_DOC_IDS, collectQueryClasses } from "./core/index.js";
|
|
23
|
+
export type { EncryptedPayload, ClassBuildOptions } from "./core/index.js";
|
|
24
|
+
/**
|
|
25
|
+
* Moving application content between stacks, without the datamodel that describes it.
|
|
26
|
+
*/
|
|
27
|
+
export { CONTENT_EXPORT_FORMAT, META_CLASSES, isContentClassName, isContentDocument, isContentRelation, } from "./core/index.js";
|
|
28
|
+
export type { ContentExport, ContentExportOptions, ContentImportOptions, ContentImportReport, ContentImportIssue, } from "./core/index.js";
|
|
29
|
+
export type { SyncDirection, SyncState, SyncStatus, StackSyncOptions, DocStackSyncOptions, RemoteResolver, SyncMetaDoc, InternalDocFilterOptions, ClassFilterOptions, TenantScope, } from "./core/index.js";
|
|
30
|
+
/**
|
|
31
|
+
* Document-modelling types, re-exported from `@docstack/shared`.
|
|
32
|
+
*
|
|
33
|
+
* These describe the values consumers have to construct themselves — most of all
|
|
34
|
+
* `Patch`, which `StackOptions.patches` asks for. `@docstack/shared` is an internal
|
|
35
|
+
* package, so surfacing them here is the only import path an application has.
|
|
36
|
+
*
|
|
37
|
+
* Note that `Document` shadows the DOM's global `Document` in whichever module imports
|
|
38
|
+
* it; alias it (`import type { Document as DocStackDocument }`) in code that needs both.
|
|
39
|
+
*/
|
|
40
|
+
export type { AttributeType, AttributeTypeConfig, AttributeModel, ClassModel, DomainModel, TriggerModel, Document, RelationDocument, Patch, SelectAST, UnionAST, ClientCredentials, DocstackReady, StackConfig, StackOptions, } from "@docstack/shared";
|
|
4
41
|
export default DocStack;
|