@qaecy/cue-sdk 0.0.54 → 0.0.57

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/lib/models.d.ts CHANGED
@@ -21,6 +21,13 @@ export interface CueSdkConfig {
21
21
  appId?: string;
22
22
  /** Firebase Measurement ID. Defaults to the QAECY demo app if omitted. */
23
23
  measurementId?: string;
24
+ /**
25
+ * Host serving Firebase's sign-in handler (`/__/auth/*`). Google and
26
+ * Microsoft show it on their sign-in screens, so an app that proxies the
27
+ * handler on its own domain passes that domain here. Defaults to
28
+ * `<project>.firebaseapp.com`.
29
+ */
30
+ authDomain?: string;
24
31
  /** Target environment. Defaults to 'production'. */
25
32
  environment?: CueEnvironment;
26
33
  /** Override individual endpoint URLs. Takes precedence over environment. */
@@ -33,7 +40,7 @@ export interface CueSdkConfig {
33
40
  export interface CueStorageConfig {
34
41
  /**
35
42
  * Per-bucket driver. `firebase` (the default) uses Firebase Storage and its
36
- * security rules; `gateway` uses the gateway's `/commands/storage` endpoints,
43
+ * security rules; `gateway` uses the gateway's `/bff/storage` endpoints,
37
44
  * which work on any backend the deployment runs (GCS, MinIO, S3).
38
45
  */
39
46
  drivers?: Partial<Record<BlobBucket, BlobDriverKind>>;
@@ -180,7 +187,7 @@ export interface ProjectSettings {
180
187
  * Absent means English only, which is what every project resolved to before
181
188
  * this field existed.
182
189
  *
183
- * Read by `writers-commands` (stamped onto `ProjectSchema.languages` on every
190
+ * Read by `writers-cue-bff` (stamped onto `ProjectSchema.languages` on every
184
191
  * schema write), the schema-suggestion endpoint (which languages a proposed
185
192
  * term is translated into), and the translation enricher (its targets, minus
186
193
  * the pivot).
@@ -257,6 +264,35 @@ export interface ProjectData {
257
264
  /** Set by a superadmin's soft delete — the project doc, index, and storage remain intact. */
258
265
  deleted?: boolean;
259
266
  deletedAt?: string | null;
267
+ /** Who owned the project when — absent until the first transfer (see `CueAdmin.transferProject`). */
268
+ ownershipHistory?: ProjectOwnershipPeriod[];
269
+ /** Orgs that owned the project before; their earlier consumption stays on their balance. */
270
+ formerOrganizationIDs?: string[];
271
+ }
272
+ /** One stretch of ownership, running from `from` until the next period's `from`. */
273
+ export interface ProjectOwnershipPeriod {
274
+ organizationID: string;
275
+ from: string;
276
+ transferId?: string;
277
+ transferredBy?: string;
278
+ /** Credits moved from the previous owner as part of the transfer (0 = none). */
279
+ creditTransfer?: number;
280
+ }
281
+ /** Body of `CueAdmin.transferProject`. */
282
+ export interface TransferProjectRequest {
283
+ organizationID: string;
284
+ /** The owner the caller saw — the server answers 409 if it has changed since. */
285
+ expectedCurrentOrganizationID: string;
286
+ /** Credits to move from the current owner to the new one; required, 0 = none. */
287
+ creditTransfer: number;
288
+ /** Client-generated UUID. Repeat it to retry a failed credit transfer. */
289
+ transferId: string;
290
+ }
291
+ /** `creditTransferFailed` means the project moved but its credits did not — retry with the same `transferId`. */
292
+ export interface TransferProjectResult {
293
+ project: ProjectData;
294
+ creditTransferFailed: boolean;
295
+ creditTransferError?: string;
260
296
  }
261
297
  export interface CreateProjectOptions {
262
298
  /** The organization this project belongs to */
@@ -590,6 +626,10 @@ export interface OrgCreditsDto {
590
626
  available: number;
591
627
  plan: OrgPlanSummary;
592
628
  }
629
+ /** An {@link OrgCreditsDto} tagged with the org it was fetched for — what `CueProfile.orgCredits` holds. */
630
+ export interface OrgCredits extends OrgCreditsDto {
631
+ orgId: string;
632
+ }
593
633
  /** Consumption for a single calendar month (`YYYY-MM`, UTC), keyed by the file's own upload time. */
594
634
  export interface MonthlyConsumptionDto {
595
635
  unitsConsumed: number;
@@ -601,6 +641,12 @@ export interface ProjectConsumptionReportDto {
601
641
  name?: string;
602
642
  /** Keyed by `YYYY-MM` (UTC). */
603
643
  monthly: Record<string, MonthlyConsumptionDto>;
644
+ /** Set when the org handed the project to another org; `monthly` then covers only its own ownership. */
645
+ transferredTo?: {
646
+ organizationID: string;
647
+ name?: string;
648
+ at: string;
649
+ };
604
650
  }
605
651
  /** Per-project, per-month consumption breakdown for an org — see {@link OrgCreditsDto} for the org-level totals. */
606
652
  export interface OrgConsumptionReportDto {
@@ -718,6 +764,8 @@ export interface CustomAppRecord {
718
764
  tone: string;
719
765
  authorId: string;
720
766
  authorName: string;
767
+ /** Set on a copy made into another organization via `cue.api.apps.copy` — the id of the original. */
768
+ copiedFrom?: string;
721
769
  createdAt: string;
722
770
  updatedAt: string;
723
771
  }
@@ -750,10 +798,10 @@ export interface RDFWritingDoc {
750
798
  lastRDFWrite: string;
751
799
  }
752
800
  /**
753
- * `processing` covers the upload→artifact window: a file has been uploaded and a
754
- * processor is working on it, but no `.ttl` exists yet so none of the RDF
755
- * write/load/resolution tracking has begun. It is the *lowest*-precedence stage,
756
- * so a project already committing RDF never appears to fall back to it.
801
+ * The project's stage, derived from its documents: `processing` while any
802
+ * document is on its way to `stored`, `enriching` while resolution runs. The
803
+ * detail is in `documentCounts`. `writing` and `loading` are no longer emitted
804
+ * by current servers.
757
805
  */
758
806
  export type ProcessingStage = 'idle' | 'processing' | 'writing' | 'loading' | 'enriching';
759
807
  /**
@@ -761,16 +809,17 @@ export type ProcessingStage = 'idle' | 'processing' | 'writing' | 'loading' | 'e
761
809
  *
762
810
  * - `uploaded` — in storage, no processor output yet
763
811
  * - `processing` — a processor has emitted artifacts (markdown, images, fragments)
764
- * - `extracting` — RDF exists; processing or extraction is still outstanding
765
- * - `ready` — done up to and including extraction; waiting to be bundled
766
- * - `stored` — ready, and every `.ttl` produced so far is bundled
812
+ * - `extracting` — processing or extraction outstanding, or its RDF not yet bundled
813
+ * - `stored` — done through extraction, and every `.ttl` produced so far is bundled
767
814
  * - `failed` — processing errored
768
815
  *
769
- * `stored` is not strictly final: an enricher producing further RDF later moves
770
- * the document back to `ready` until that RDF is bundled too, which is a
771
- * faithful description of reality rather than a bug.
816
+ * Partial problems (a page whose extraction failed) do not fail the document;
817
+ * they are listed in `gaps`. `stored` is not strictly final: RDF arriving later
818
+ * moves the document back to `extracting` until it is bundled too.
772
819
  */
773
- export type DocumentProcessingStage = 'uploaded' | 'processing' | 'extracting' | 'ready' | 'stored' | 'failed';
820
+ export type DocumentProcessingStage = 'uploaded' | 'processing' | 'extracting' | 'stored' | 'failed';
821
+ /** How many of a project's documents are in each stage. */
822
+ export type DocumentStageCounts = Record<DocumentProcessingStage, number>;
774
823
  /** Per-document pipeline progress for one uploaded file. */
775
824
  export interface DocumentProgress {
776
825
  documentUUID: string;
@@ -798,6 +847,8 @@ export interface DocumentProgress {
798
847
  export interface ProjectProcessingSummary {
799
848
  projectId: string;
800
849
  stage: ProcessingStage;
850
+ /** Absent on older servers. */
851
+ documentCounts?: DocumentStageCounts;
801
852
  pendingDocumentCount: number;
802
853
  failedDocumentCount: number;
803
854
  lastActivityAt?: string;
@@ -818,10 +869,98 @@ export interface MyProcessingStatus {
818
869
  */
819
870
  truncated?: boolean;
820
871
  }
872
+ /** Options for `CueApi.reprocessDocument` — mirrors the service's `ReprocessDocumentDto`. */
873
+ export interface ReprocessDocumentOptions {
874
+ removeGraphs?: boolean;
875
+ removeProcessed?: boolean;
876
+ /** Publish even when the raw blob carries `skip_processing` (does not clear the flag). */
877
+ force?: boolean;
878
+ resetAttempts?: boolean;
879
+ dryRun?: boolean;
880
+ }
881
+ /** 202 body: the reprocess is running, follow `processId` on the status socket. */
882
+ export interface ReprocessAccepted {
883
+ processId: string;
884
+ projectId: string;
885
+ documentUUID: string;
886
+ status: string;
887
+ }
888
+ /** 200 body for a `dryRun` request — what a real run would purge. */
889
+ export interface ReprocessPlan {
890
+ dryRun: true;
891
+ projectId: string;
892
+ documentUUID: string;
893
+ graphs: string[];
894
+ quads: number;
895
+ blobs: string[];
896
+ rawBlobPresent: boolean;
897
+ /**
898
+ * Count of this document's mentions already resolved into a canonical entity
899
+ * elsewhere in the project — purging leaves that entity's link dangling until
900
+ * the pipeline re-resolves the same text.
901
+ */
902
+ resolvedMentionsAtRisk: number;
903
+ }
904
+ export declare const isReprocessPlan: (r: ReprocessAccepted | ReprocessPlan) => r is ReprocessPlan;
905
+ /** One entity mention to create — mirrors the service's `CreateEntityMentionDto`. */
906
+ export interface EntityMentionInput {
907
+ mention: {
908
+ iri: string;
909
+ value: string;
910
+ entityCategories: string[];
911
+ description?: string | null;
912
+ resolvesTo?: string | null;
913
+ properties?: string[];
914
+ /** Subjects (e.g. selectors) this mention is made in. */
915
+ mentions?: string[];
916
+ relationships?: {
917
+ predicate: string;
918
+ objectIri: string;
919
+ }[];
920
+ };
921
+ namedGraph: string;
922
+ comment?: string;
923
+ }
924
+ /** One entity mention to delete — mirrors the service's `DeleteEntityMentionDto`. */
925
+ export interface EntityMentionDeletion {
926
+ iri: string;
927
+ comment?: string;
928
+ }
929
+ /** One selector to create — mirrors the service's `CreateSelectorDto`. */
930
+ export interface SelectorInput {
931
+ iri: string;
932
+ type: string;
933
+ selectorSubjects: string[];
934
+ selectorObject: string;
935
+ value: string;
936
+ namedGraph: string;
937
+ comment?: string;
938
+ }
939
+ /** Replaces a subject's content categories — mirrors the service's `ChangeObjectIRIRequestDto`. */
940
+ export interface ContentCategoryChange {
941
+ subject: string;
942
+ existingValues: string[];
943
+ newValues: string[];
944
+ comment?: string;
945
+ }
946
+ /** Outcome of one graph edit — mirrors the service's `MutationResult`. */
947
+ export interface EditResult {
948
+ message: string;
949
+ success: boolean;
950
+ insertCount?: number;
951
+ iri?: string;
952
+ errorCode?: string;
953
+ }
954
+ /** Outcome of a batch of graph edits — mirrors the service's `BatchMutationResult`. */
955
+ export interface BatchEditResult {
956
+ results: EditResult[];
957
+ successCount: number;
958
+ failureCount: number;
959
+ }
821
960
  /** Lifecycle of a superadmin document-reprocess request. */
822
961
  export type ReprocessJobStatus = 'queued' | 'purging-rdf' | 'purging-blobs' | 'publishing' | 'succeeded' | 'failed';
823
962
  /**
824
- * Progress of one document reprocess (`POST /commands/document/:uuid/reprocess`),
963
+ * Progress of one document reprocess (`POST /bff/document/:uuid/reprocess`),
825
964
  * pushed on the same socket as the rest of the pipeline status.
826
965
  */
827
966
  export interface DocumentReprocessJob {
@@ -843,7 +982,7 @@ export interface DocumentReprocessJob {
843
982
  finishedAt?: string;
844
983
  }
845
984
  /**
846
- * Aggregated, per-project pipeline status pushed live by the `accessors-data-views`
985
+ * Aggregated, per-project pipeline status pushed live by the `writers-cue-bff`
847
986
  * processing-status WebSocket (see `CueProcessingApi.watchStatus`). Shape mirrors
848
987
  * `cue-ui`'s `ProcessingStatus` (views/project-settings/models.ts) so it can be
849
988
  * passed straight through to `<cue-project-settings>` / `<cue-portal-upload>`.
@@ -873,9 +1012,11 @@ export interface ProcessingStatus {
873
1012
  * this as "the recent ones" and rely on the counts below for totals.
874
1013
  */
875
1014
  documents?: DocumentProgress[];
1015
+ /** How many documents are in each stage. Exact. Absent on older servers. */
1016
+ documentCounts?: DocumentStageCounts;
876
1017
  /**
877
1018
  * Documents not yet in a terminal stage. Exact even when `documents` was
878
- * truncated. Optional because a client may be talking to a data-views
1019
+ * truncated. Optional because a client may be talking to a writers-cue-bff
879
1020
  * deployment predating per-document tracking, which omits it — treat absent as
880
1021
  * "unknown", not zero.
881
1022
  */
@@ -14,7 +14,7 @@ export interface MyProcessingStatusWatcher {
14
14
  close(): void;
15
15
  }
16
16
  /**
17
- * Live pipeline-progress status, pushed by the `accessors-data-views`
17
+ * Live pipeline-progress status, pushed by `writers-cue-bff`'s
18
18
  * processing-status WebSockets. Backs the upload modal, the project-settings
19
19
  * "processing" indicators, and the header's cross-project badge.
20
20
  */
package/lib/profile.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import { UserInfo } from 'firebase/auth';
2
- import { APIKeyDoc, APIKeyInfo, FileTypeBreakdownDto, OrgConsumptionReportDto, OrgCreditsDto, OrgMember, OrganizationData, ProfileSSOAccount, TrafficReportDto, UsageReportDto } from './models';
2
+ import { APIKeyDoc, APIKeyInfo, FileTypeBreakdownDto, OrgConsumptionReportDto, OrgCredits, OrgCreditsDto, OrgMember, OrganizationData, ProfileSSOAccount, TrafficReportDto, UsageReportDto } from './models';
3
3
  import { CueAuth } from './auth';
4
4
  import { ReadonlySignal } from './signal';
5
+ import { OrgSignUpPlan } from './signup';
5
6
  export declare class CueProfile {
6
7
  private readonly _auth;
7
8
  private readonly _gatewayUrl;
@@ -11,10 +12,12 @@ export declare class CueProfile {
11
12
  * by `getOrgCredits()` and by the sync layer after every `previewSync`/
12
13
  * `sync`/`computeCredits` call, so consumers that bind to this signal see
13
14
  * balance changes (e.g. after an upload) without polling or manually
14
- * re-fetching. Angular consumers bridge via
15
+ * re-fetching. The value carries the `orgId` it belongs to: fetches for
16
+ * different orgs can resolve out of order, so check it against the org on
17
+ * screen before showing the balance. Angular consumers bridge via
15
18
  * `effect(() => sig.set(cue.profile.orgCredits.get()))` + `.subscribe(...)`.
16
19
  */
17
- readonly orgCredits: ReadonlySignal<OrgCreditsDto | undefined>;
20
+ readonly orgCredits: ReadonlySignal<OrgCredits | undefined>;
18
21
  constructor(_auth: CueAuth, _gatewayUrl: string);
19
22
  private _url;
20
23
  private _fetch;
@@ -34,7 +37,12 @@ export declare class CueProfile {
34
37
  updatePassword(currentPassword: string, newPassword: string): Promise<void>;
35
38
  /** Adds (sets) a password for an account that currently only uses SSO. */
36
39
  addPassword(password: string): Promise<void>;
37
- /** Requests an e-mail change. Sends a verification e-mail to the new address. */
40
+ /**
41
+ * Requests an e-mail change. The backend checks `password` and sends a
42
+ * confirmation link to the new address; the change happens when it's
43
+ * followed. Throws `CueRequestError` with `code` 'wrongPassword' |
44
+ * 'emailExists' | 'sameEmail' | 'noEmail' | 'tooManyAttempts'.
45
+ */
38
46
  updateEmail(newEmail: string, password: string): Promise<void>;
39
47
  /** Creates a new API key for the current user. */
40
48
  createAPIKey(expiration: string): Promise<APIKeyDoc>;
@@ -46,6 +54,39 @@ export declare class CueProfile {
46
54
  listOrganizations(): Promise<(Pick<OrganizationData, 'id' | 'name'> & {
47
55
  isAdmin: boolean;
48
56
  })[]>;
57
+ /**
58
+ * Creates an organisation with the current user as its admin — for a user
59
+ * who belongs to none. It claims the user's email domain when that email is
60
+ * verified, not a free-mail provider and not claimed already; otherwise it is
61
+ * created without a domain. Throws `CueRequestError` with `code`
62
+ * 'alreadyInOrganisation' when the user already belongs to one.
63
+ */
64
+ createOwnOrganization(orgName: string, plan: OrgSignUpPlan): Promise<{
65
+ orgId: string;
66
+ orgName: string;
67
+ domains: string[];
68
+ checkoutUrl?: string;
69
+ }>;
70
+ /**
71
+ * Asks to join the organisation owning `domain` (e.g. `qaecy.com`); its
72
+ * admins get an email. Resolves the same whether or not any organisation
73
+ * owns the domain, so it can't be used to find out. Throws `CueRequestError`
74
+ * with `code` 'emailNotVerified' | 'invalidDomain'.
75
+ */
76
+ requestToJoinOrganization(domain: string): Promise<void>;
77
+ /**
78
+ * Joins the organisation owning the current user's email domain — only once
79
+ * that email is verified, which is why sign-up itself never joins one. Call
80
+ * it when a signed-in user has no organisation; `joined` is false when the
81
+ * email is unverified or no organisation owns the domain.
82
+ */
83
+ joinOrganizationByEmailDomain(): Promise<{
84
+ joined: boolean;
85
+ orgId?: string;
86
+ orgName?: string;
87
+ }>;
88
+ /** POSTs JSON and surfaces the backend's error `code`, for calls whose failures a UI maps. */
89
+ private _fetchCoded;
49
90
  /** Returns all members of the given organisation. Caller must be an org admin or superadmin. */
50
91
  getOrgMembers(orgId: string): Promise<OrgMember[]>;
51
92
  /** Returns just the given organisation's admins. Caller must be a member (or admin/superadmin). */
@@ -32,6 +32,37 @@ export interface EntityRelationshipInput extends EntityCategoryInput {
32
32
  sources: string[];
33
33
  targets: string[];
34
34
  }
35
+ /** A declared canonical's new value. Changing it changes the canonical's IRI, and everything pointing at it moves too. */
36
+ export interface RenameCanonicalInput {
37
+ categoryKey: string;
38
+ canonicalKey: string;
39
+ newValue: string;
40
+ /** The schema revision the caller read; a stale one is refused. */
41
+ revision: number;
42
+ /** When the new value is already a canonical of the category. Defaults to `merge`. */
43
+ onCollision?: 'merge' | 'refuse';
44
+ /** Record the old value as a resolved form of the new canonical. Defaults to `false`. */
45
+ keepOldAsAlias?: boolean;
46
+ /** Report what would change and write nothing. */
47
+ dryRun?: boolean;
48
+ }
49
+ export interface RenameCanonicalResult {
50
+ oldIri: string;
51
+ newIri: string;
52
+ collision: boolean;
53
+ /** Set when the collision is with another canonical declared in the schema. */
54
+ collidesWithKey?: string;
55
+ dryRun: boolean;
56
+ quads: number;
57
+ mentions: number;
58
+ files: number;
59
+ graphs: number;
60
+ dataSources: number;
61
+ /** The saved schema's revision; absent on a dry run. */
62
+ revision?: number;
63
+ /** Follow-up steps that failed after the graph moved — running the same rename again finishes them. */
64
+ warnings: string[];
65
+ }
35
66
  /**
36
67
  * One project the caller could take an existing schema from — what
37
68
  * `listSchemaSources` lists.
@@ -53,7 +84,7 @@ export interface SchemaSource {
53
84
  relations: number;
54
85
  }
55
86
  /**
56
- * Client for writers-commands' semantic-template CRUD endpoints — persists a
87
+ * Client for writers-cue-bff's semantic-template CRUD endpoints — persists a
57
88
  * project's custom extraction/classification schema (content categories,
58
89
  * entity categories, entity relationships) and reloads the project's
59
90
  * `databases-cue` schema graph after every mutation.
@@ -124,6 +155,11 @@ export declare class CueSemanticTemplate {
124
155
  reloadSchema(projectId: string): Promise<MutationResult>;
125
156
  private _get;
126
157
  private _send;
158
+ /**
159
+ * Changes a declared canonical's value. Needs the syncer or admin role. Run it with `dryRun`
160
+ * first to see what would move and whether the new value collides.
161
+ */
162
+ renameCanonical(projectId: string, input: RenameCanonicalInput): Promise<RenameCanonicalResult>;
127
163
  private _post;
128
164
  private _delete;
129
165
  private _errorMessage;
package/lib/signup.d.ts CHANGED
@@ -39,17 +39,16 @@ export declare class CueSignUp {
39
39
  private readonly _gatewayUrl;
40
40
  constructor(_gatewayUrl: string);
41
41
  /**
42
- * Register a new user by name and email.
43
- * The backend validates that the email domain belongs to an existing organisation,
44
- * creates the Firebase Auth account, assigns org membership, and — when no
45
- * `password` is given — dispatches a "set your password" email to the
46
- * address provided. `termsVersion`, when given, is recorded as accepted
47
- * immediately so the user isn't asked again on their next sign-in.
48
- * Returns the new user's UID and the organisation name on success.
42
+ * Register a new user by name and email. The account starts without an
43
+ * organisation and the answer is the same whatever the email's domain; the
44
+ * user joins the organisation owning that domain once the email is verified
45
+ * (see `CueProfile.joinOrganizationByEmailDomain`). When no `password` is
46
+ * given, a "set your password" email is sent. `termsVersion`, when given, is
47
+ * recorded as accepted immediately so the user isn't asked again on their
48
+ * next sign-in.
49
49
  */
50
50
  signUp(name: string, email: string, password?: string, termsVersion?: string): Promise<{
51
51
  uid: string;
52
- orgName: string;
53
52
  }>;
54
53
  /**
55
54
  * Self-service sign-up that creates a new organisation together with its
@@ -3,7 +3,7 @@ import { CueAuth } from './auth';
3
3
  * Records portal view-opens for usage reporting (per-user, per-view, per-project) —
4
4
  * fed into the same GCS-aggregate pipeline as gateway traffic tracking, but written
5
5
  * by the frontend directly instead of Kong's `http-log` plugin. See
6
- * apps/writers/commands/src/app/admin/usage/usage-ingest.service.ts.
6
+ * apps/writers/cue-bff/src/app/admin/usage/usage-ingest.service.ts.
7
7
  */
8
8
  export declare class CueUsageStats {
9
9
  private readonly _auth;