@north-light/api 0.3.549 → 0.3.551

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.
@@ -1,5 +1,5 @@
1
1
  /** The contract level this build serves and requires. Written by `scripts/contract.mjs release`; never edit by hand. */
2
- export declare const CONTRACT_LEVEL = "1.30";
2
+ export declare const CONTRACT_LEVEL = "1.31";
3
3
  /** Request header naming the one contract level the caller needs, e.g. `1.3`. Optional: absent means no check. */
4
4
  export declare const REQUIRED_CONTRACT_HEADER = "Crouter-Required-Contract";
5
5
  /** Response header listing the contract levels the server serves, comma-separated, one per major, e.g. `1.3`. */
@@ -12,7 +12,7 @@
12
12
  //
13
13
  // PURITY (spec §3.1): Node built-ins + `src/api/*` only.
14
14
  /** The contract level this build serves and requires. Written by `scripts/contract.mjs release`; never edit by hand. */
15
- export const CONTRACT_LEVEL = '1.30';
15
+ export const CONTRACT_LEVEL = '1.31';
16
16
  /** Request header naming the one contract level the caller needs, e.g. `1.3`. Optional: absent means no check. */
17
17
  export const REQUIRED_CONTRACT_HEADER = 'Crouter-Required-Contract';
18
18
  /** Response header listing the contract levels the server serves, comma-separated, one per major, e.g. `1.3`. */
@@ -19,7 +19,7 @@ export interface RegisterCustomObjectRequestDTO {
19
19
  events?: Record<string, CustomEventSpecDTO>;
20
20
  receiver?: CustomReceiverDTO;
21
21
  rotate_token?: boolean;
22
- /** Who can read the instance: `public` (default), `friends` or `private`. Setting it on an existing instance changes it. */
22
+ /** Who can read the instance: `public` (default) or `private`. Setting it on an existing instance changes it. */
23
23
  privacy?: PrivacyName;
24
24
  }
25
25
  export interface RegisterCustomObjectResponseDTO {
@@ -27,9 +27,17 @@ export interface DocWriteRequest {
27
27
  unlisted?: boolean;
28
28
  lint_ignore?: string[];
29
29
  extensions?: Record<string, Record<string, unknown>>;
30
+ /** The app type the document is an instance of (`firstlight/memory`), in the calling app's own namespace. The app's schema then governs who reads it. */
31
+ schema_type?: string;
32
+ /** Facts written in the same transaction as the document, with resource `<schema_type>:<new object id>`. Subject: `user:<id>`, `<type>:<id>` or `<type>:<id>#<relation>`. */
33
+ relations?: DocRelationDTO[];
30
34
  /** The caller's cwd, for `--owner repo` resolution. */
31
35
  cwd?: string;
32
36
  }
37
+ export interface DocRelationDTO {
38
+ relation: string;
39
+ subject: string;
40
+ }
33
41
  /** `name` is canonical: `<owner-handle>/<name>`. */
34
42
  /** `unresolved_links`: names that match nothing in the writer's view. `remote_links`: names whose
35
43
  * first segment is no owner on this runtime — on another runtime, or misspelled. */
@@ -99,6 +107,10 @@ export interface DocRevisionDTO {
99
107
  verbatim: boolean;
100
108
  created_at: string;
101
109
  parents: string[];
110
+ /** The app that made the revision (`app:firstlight`), or null. */
111
+ acting_app: string | null;
112
+ /** The person the revision was made for (`user:<id>`), or null. */
113
+ acting_for: string | null;
102
114
  }
103
115
  export interface DocHistoryDTO {
104
116
  object: ObjectDTO;
@@ -1,4 +1,4 @@
1
- export declare const PRIVACY_LEVELS_DTO: readonly ["public", "friends", "private"];
1
+ export declare const PRIVACY_LEVELS_DTO: readonly ["public", "private"];
2
2
  export type PrivacyName = typeof PRIVACY_LEVELS_DTO[number];
3
3
  export type OwnerTypeName = 'person' | 'app' | 'repo' | 'profile' | 'node' | 'document' | 'job';
4
4
  export interface ObjectOwnerDTO {
@@ -34,6 +34,8 @@ export interface ObjectDTO {
34
34
  preview: string;
35
35
  created_at: string;
36
36
  deleted_at: string | null;
37
+ /** The app type a document is an instance of (`firstlight/memory`); null for a document governed by `crtr/object`. Present on documents. */
38
+ schema_type?: string | null;
37
39
  /** Present on an instance of a custom kind. */
38
40
  kind_decl?: ObjectKindDeclDTO;
39
41
  }
@@ -141,6 +143,12 @@ export interface ObjectListRequest {
141
143
  cursor?: string;
142
144
  /** List only this machine (`runtime:<id>`), paging through its cursor. `self` lists only this machine without labels. */
143
145
  machine?: string;
146
+ /** Documents whose `extensions` hold these top-level fields (equality), e.g. `{ firstlight: { workspace_id: 'w1', state: 'active' } }`. Applied inside the permission-filtered query, before `limit`. */
147
+ extensions?: Record<string, Record<string, unknown>>;
148
+ /** Documents that are instances of this app type (`firstlight/memory`). */
149
+ schema_type?: string;
150
+ /** Only objects the caller reaches through a share and not through its own tree. */
151
+ shared?: boolean;
144
152
  }
145
153
  export interface ObjectListItemDTO extends ObjectDTO {
146
154
  /** The machine of your account that homes the row; set on a merged or `--machine` listing. */
@@ -148,6 +156,10 @@ export interface ObjectListItemDTO extends ObjectDTO {
148
156
  summary?: string | null;
149
157
  /** A document's rule count. */
150
158
  rules?: number;
159
+ /** A document's `extensions`, as stored. Present on document items. */
160
+ extensions?: Record<string, Record<string, unknown>>;
161
+ /** A document's app type, or null. Present on document items. */
162
+ schema_type?: string | null;
151
163
  }
152
164
  export type MachineListState = 'ok' | 'unreachable' | 'too_old';
153
165
  /** How one machine answered a merged listing; `more` says its first page was not all of it (page it with `--machine`). */
@@ -172,7 +184,11 @@ export interface ObjectSearchRequest {
172
184
  kind?: string;
173
185
  owner?: string;
174
186
  limit?: number;
187
+ /** As on `ObjectListRequest`: applied inside the query in every search mode (name, `body`, `grep`). */
188
+ extensions?: Record<string, Record<string, unknown>>;
189
+ schema_type?: string;
175
190
  }
191
+ /** `object` is an `ObjectListItemDTO`, so a document hit carries its `extensions` and `schema_type` there. */
176
192
  export interface ObjectSearchHitDTO {
177
193
  object: ObjectListItemDTO;
178
194
  matches?: Array<{
@@ -2,4 +2,4 @@
2
2
  // watch, unwatch, edges) over documents, nodes, jobs and owners.
3
3
  //
4
4
  // PURITY (spec §3.1): Node built-ins + `src/api/*` only.
5
- export const PRIVACY_LEVELS_DTO = ['public', 'friends', 'private'];
5
+ export const PRIVACY_LEVELS_DTO = ['public', 'private'];
@@ -0,0 +1,76 @@
1
+ /** `POST /v1/schemas`: register or update the calling app's permission schema (SpiceDB syntax). */
2
+ export interface SchemaRegisterRequest {
3
+ namespace: string;
4
+ source: string;
5
+ }
6
+ export interface SchemaRegisterDTO {
7
+ namespace: string;
8
+ version: number;
9
+ changed: boolean;
10
+ }
11
+ /** One relation fact. `resource` is `<type>:<id>` within the caller's namespace; `subject` is `user:<id>`, `<type>:<id>` or `<type>:<id>#<relation>`. */
12
+ export interface FactDTO {
13
+ resource: string;
14
+ relation: string;
15
+ subject: string;
16
+ }
17
+ /** `POST /v1/relations`: idempotent writes and deletes of facts. */
18
+ export interface RelationsWriteRequest {
19
+ write?: FactDTO[];
20
+ delete?: FactDTO[];
21
+ }
22
+ /** `PUT /v1/relations`: the facts `(resource, relation, *)` become exactly `subjects`. */
23
+ export interface RelationsReplaceRequest {
24
+ resource: string;
25
+ relation: string;
26
+ subjects: string[];
27
+ }
28
+ export interface RelationsChangedDTO {
29
+ written: number;
30
+ deleted: number;
31
+ }
32
+ /** `GET /v1/relations?resource=<type>:<id>`. */
33
+ export interface RelationsListDTO {
34
+ items: FactDTO[];
35
+ }
36
+ /** `POST /v1/check`: may `subject` do `permission` on `resource` (`<type>:<id>`, or a crouter object id with `read|edit|message|use`). */
37
+ export interface CheckRequest {
38
+ subject: string;
39
+ permission: string;
40
+ resource: string;
41
+ }
42
+ export interface CheckDTO {
43
+ allowed: boolean;
44
+ }
45
+ /** The CLI verbs of a share and the relation each writes on a `crtr/object`. */
46
+ export declare const SHARE_VERBS: readonly ["read", "edit", "message", "use"];
47
+ export type ShareVerb = typeof SHARE_VERBS[number];
48
+ /** `POST /v1/objects/:ref/shares`: share the object. `subject` is `user:<id>`, `team:<id>` or `user:*` (everyone). */
49
+ export interface ShareRequest {
50
+ verb: ShareVerb;
51
+ subject: string;
52
+ }
53
+ /** `DELETE /v1/objects/:ref/shares?verb=&subject=`: revoke it. Same pair as the request. */
54
+ export interface ShareRevokeQuery {
55
+ verb: ShareVerb;
56
+ subject: string;
57
+ }
58
+ /** The object and fact a share call acted on; `changed` is false when the fact already held (or was already absent). */
59
+ export interface ShareChangedDTO {
60
+ id: string;
61
+ name: string;
62
+ relation: string;
63
+ subject: string;
64
+ changed: boolean;
65
+ }
66
+ /** `GET /v1/objects/:ref/shares`: who the object is shared with, for those who may share it. */
67
+ export interface ShareListDTO {
68
+ id: string;
69
+ name: string;
70
+ items: Array<{
71
+ verb: ShareVerb;
72
+ subject: string;
73
+ written_by: string;
74
+ created_at: string;
75
+ }>;
76
+ }
@@ -0,0 +1,5 @@
1
+ // Permission DTOs — `POST /v1/schemas`, `/v1/relations` and `POST /v1/check`.
2
+ //
3
+ // PURITY (spec §3.1): Node built-ins + `src/api/*` only.
4
+ /** The CLI verbs of a share and the relation each writes on a `crtr/object`. */
5
+ export const SHARE_VERBS = ['read', 'edit', 'message', 'use'];
@@ -49,5 +49,6 @@ export * from './dto/chat-inventory.js';
49
49
  export * from './dto/analytics.js';
50
50
  export * from './dto/custom-objects.js';
51
51
  export * from './dto/plugins.js';
52
- export type { DeliveryRuleDTO, DocEditRequest, DocEditedDTO, DocKindName, DocUnsetField, DocWriteRequest, DocWrittenDTO, DocLinkReportDTO, DocStaleDTO, RuleDeliverName, RuleOnName, } from './dto/docs.js';
53
- export type { DocumentReadData, ObjectDTO, ObjectReadDTO, WatchRequest, WatchResultDTO, UnwatchQuery, UnwatchResultDTO } from './dto/objects.js';
52
+ export * from './dto/permissions.js';
53
+ export type { DeliveryRuleDTO, DocDeletedDTO, DocHistoryDTO, DocRelationDTO, DocRevisionDTO, DocEditRequest, DocEditedDTO, DocKindName, DocUnsetField, DocWriteRequest, DocWrittenDTO, DocLinkReportDTO, DocStaleDTO, RuleDeliverName, RuleOnName, } from './dto/docs.js';
54
+ export type { DocumentReadData, ObjectDTO, ObjectListDTO, ObjectListItemDTO, ObjectListRequest, ObjectSearchDTO, ObjectSearchHitDTO, ObjectSearchRequest, ObjectReadDTO, WatchRequest, WatchResultDTO, UnwatchQuery, UnwatchResultDTO } from './dto/objects.js';
package/dist/api/index.js CHANGED
@@ -46,3 +46,4 @@ export * from './dto/chat-inventory.js';
46
46
  export * from './dto/analytics.js';
47
47
  export * from './dto/custom-objects.js';
48
48
  export * from './dto/plugins.js';
49
+ export * from './dto/permissions.js';
@@ -157,12 +157,16 @@ export declare const routes: {
157
157
  readonly customObjectEvents: (ref: string) => string;
158
158
  readonly customObjectDeliveries: (ref: string) => string;
159
159
  readonly customObjectAck: (ref: string) => string;
160
+ readonly objectShares: (ref: string) => string;
160
161
  readonly objectEdges: (ref: string) => string;
161
162
  readonly docs: () => string;
162
163
  readonly doc: (ref: string) => string;
163
164
  readonly docMove: (ref: string) => string;
164
165
  readonly docHistory: (ref: string) => string;
165
166
  readonly docsLint: () => string;
167
+ readonly schemas: () => string;
168
+ readonly relations: () => string;
169
+ readonly check: () => string;
166
170
  readonly pluginAppToken: (name: string) => string;
167
171
  readonly pluginCallHeaders: (name: string) => string;
168
172
  readonly documentsBrowserAccess: () => string;
@@ -190,12 +190,16 @@ export const routes = {
190
190
  customObjectEvents: (ref) => `${V}/custom-objects/${encodeURIComponent(ref)}/events`,
191
191
  customObjectDeliveries: (ref) => `${V}/custom-objects/${encodeURIComponent(ref)}/deliveries`,
192
192
  customObjectAck: (ref) => `${V}/custom-objects/${encodeURIComponent(ref)}/deliveries/ack`,
193
+ objectShares: (ref) => `${V}/objects/${encodeURIComponent(ref)}/shares`,
193
194
  objectEdges: (ref) => `${V}/objects/${encodeURIComponent(ref)}/edges`,
194
195
  docs: () => `${V}/docs`,
195
196
  doc: (ref) => `${V}/docs/${encodeURIComponent(ref)}`,
196
197
  docMove: (ref) => `${V}/docs/${encodeURIComponent(ref)}/move`,
197
198
  docHistory: (ref) => `${V}/docs/${encodeURIComponent(ref)}/history`,
198
199
  docsLint: () => `${V}/docs/lint`,
200
+ schemas: () => `${V}/schemas`,
201
+ relations: () => `${V}/relations`,
202
+ check: () => `${V}/check`,
199
203
  pluginAppToken: (name) => `${V}/plugins/${encodeURIComponent(name)}/app-token`,
200
204
  pluginCallHeaders: (name) => `${V}/plugins/${encodeURIComponent(name)}/call-headers`,
201
205
  documentsBrowserAccess: () => `${V}/documents/browser-access`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@north-light/api",
3
- "version": "0.3.549",
3
+ "version": "0.3.551",
4
4
  "description": "Typed crtrd /v1 API contract — DTOs, route builders, the error contract, the CrtrClient, and the command-plugin manifest format. Zero runtime dependencies.",
5
5
  "type": "module",
6
6
  "main": "./dist/api/index.js",