@qaecy/cue-sdk 0.0.53 → 0.0.55

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
@@ -1,5 +1,6 @@
1
1
  import { SupportedCurrency } from './currency';
2
2
  import { ComparisonResult } from '../../sync-tools/src/index';
3
+ import { BlobBucket, BlobDriverKind } from '../../databases/src/index';
3
4
  export type CueEnvironment = 'production' | 'emulator';
4
5
  export interface CueEndpoints {
5
6
  /** API gateway base URL */
@@ -26,6 +27,18 @@ export interface CueSdkConfig {
26
27
  endpoints?: Partial<CueEndpoints>;
27
28
  /** Enable verbose debug logging for all entity/document store operations. */
28
29
  verbose?: boolean;
30
+ /** How the SDK reaches object storage. Defaults to Firebase Storage for every bucket. */
31
+ storage?: CueStorageConfig;
32
+ }
33
+ export interface CueStorageConfig {
34
+ /**
35
+ * Per-bucket driver. `firebase` (the default) uses Firebase Storage and its
36
+ * security rules; `gateway` uses the gateway's `/bff/storage` endpoints,
37
+ * which work on any backend the deployment runs (GCS, MinIO, S3).
38
+ */
39
+ drivers?: Partial<Record<BlobBucket, BlobDriverKind>>;
40
+ /** Firebase Storage bucket names, for buckets on the `firebase` driver. */
41
+ buckets?: Partial<Record<BlobBucket, string>>;
29
42
  }
30
43
  export type SsoProvider = 'google' | 'microsoft';
31
44
  export interface PasswordCredentials {
@@ -167,7 +180,7 @@ export interface ProjectSettings {
167
180
  * Absent means English only, which is what every project resolved to before
168
181
  * this field existed.
169
182
  *
170
- * Read by `writers-commands` (stamped onto `ProjectSchema.languages` on every
183
+ * Read by `writers-cue-bff` (stamped onto `ProjectSchema.languages` on every
171
184
  * schema write), the schema-suggestion endpoint (which languages a proposed
172
185
  * term is translated into), and the translation enricher (its targets, minus
173
186
  * the pivot).
@@ -244,6 +257,35 @@ export interface ProjectData {
244
257
  /** Set by a superadmin's soft delete — the project doc, index, and storage remain intact. */
245
258
  deleted?: boolean;
246
259
  deletedAt?: string | null;
260
+ /** Who owned the project when — absent until the first transfer (see `CueAdmin.transferProject`). */
261
+ ownershipHistory?: ProjectOwnershipPeriod[];
262
+ /** Orgs that owned the project before; their earlier consumption stays on their balance. */
263
+ formerOrganizationIDs?: string[];
264
+ }
265
+ /** One stretch of ownership, running from `from` until the next period's `from`. */
266
+ export interface ProjectOwnershipPeriod {
267
+ organizationID: string;
268
+ from: string;
269
+ transferId?: string;
270
+ transferredBy?: string;
271
+ /** Credits moved from the previous owner as part of the transfer (0 = none). */
272
+ creditTransfer?: number;
273
+ }
274
+ /** Body of `CueAdmin.transferProject`. */
275
+ export interface TransferProjectRequest {
276
+ organizationID: string;
277
+ /** The owner the caller saw — the server answers 409 if it has changed since. */
278
+ expectedCurrentOrganizationID: string;
279
+ /** Credits to move from the current owner to the new one; required, 0 = none. */
280
+ creditTransfer: number;
281
+ /** Client-generated UUID. Repeat it to retry a failed credit transfer. */
282
+ transferId: string;
283
+ }
284
+ /** `creditTransferFailed` means the project moved but its credits did not — retry with the same `transferId`. */
285
+ export interface TransferProjectResult {
286
+ project: ProjectData;
287
+ creditTransferFailed: boolean;
288
+ creditTransferError?: string;
247
289
  }
248
290
  export interface CreateProjectOptions {
249
291
  /** The organization this project belongs to */
@@ -577,6 +619,10 @@ export interface OrgCreditsDto {
577
619
  available: number;
578
620
  plan: OrgPlanSummary;
579
621
  }
622
+ /** An {@link OrgCreditsDto} tagged with the org it was fetched for — what `CueProfile.orgCredits` holds. */
623
+ export interface OrgCredits extends OrgCreditsDto {
624
+ orgId: string;
625
+ }
580
626
  /** Consumption for a single calendar month (`YYYY-MM`, UTC), keyed by the file's own upload time. */
581
627
  export interface MonthlyConsumptionDto {
582
628
  unitsConsumed: number;
@@ -588,6 +634,12 @@ export interface ProjectConsumptionReportDto {
588
634
  name?: string;
589
635
  /** Keyed by `YYYY-MM` (UTC). */
590
636
  monthly: Record<string, MonthlyConsumptionDto>;
637
+ /** Set when the org handed the project to another org; `monthly` then covers only its own ownership. */
638
+ transferredTo?: {
639
+ organizationID: string;
640
+ name?: string;
641
+ at: string;
642
+ };
591
643
  }
592
644
  /** Per-project, per-month consumption breakdown for an org — see {@link OrgCreditsDto} for the org-level totals. */
593
645
  export interface OrgConsumptionReportDto {
@@ -705,6 +757,8 @@ export interface CustomAppRecord {
705
757
  tone: string;
706
758
  authorId: string;
707
759
  authorName: string;
760
+ /** Set on a copy made into another organization via `cue.api.apps.copy` — the id of the original. */
761
+ copiedFrom?: string;
708
762
  createdAt: string;
709
763
  updatedAt: string;
710
764
  }
@@ -737,10 +791,10 @@ export interface RDFWritingDoc {
737
791
  lastRDFWrite: string;
738
792
  }
739
793
  /**
740
- * `processing` covers the upload→artifact window: a file has been uploaded and a
741
- * processor is working on it, but no `.ttl` exists yet so none of the RDF
742
- * write/load/resolution tracking has begun. It is the *lowest*-precedence stage,
743
- * so a project already committing RDF never appears to fall back to it.
794
+ * The project's stage, derived from its documents: `processing` while any
795
+ * document is on its way to `stored`, `enriching` while resolution runs. The
796
+ * detail is in `documentCounts`. `writing` and `loading` are no longer emitted
797
+ * by current servers.
744
798
  */
745
799
  export type ProcessingStage = 'idle' | 'processing' | 'writing' | 'loading' | 'enriching';
746
800
  /**
@@ -748,15 +802,17 @@ export type ProcessingStage = 'idle' | 'processing' | 'writing' | 'loading' | 'e
748
802
  *
749
803
  * - `uploaded` — in storage, no processor output yet
750
804
  * - `processing` — a processor has emitted artifacts (markdown, images, fragments)
751
- * - `extracting` — RDF exists but is not all committed to the ledger
752
- * - `stored` — every `.ttl` produced so far is committed
805
+ * - `extracting` — processing or extraction outstanding, or its RDF not yet bundled
806
+ * - `stored` — done through extraction, and every `.ttl` produced so far is bundled
753
807
  * - `failed` — processing errored
754
808
  *
755
- * `stored` is not strictly final: an enricher producing further RDF later moves
756
- * the document back to `extracting`, which is a faithful description of reality
757
- * rather than a bug.
809
+ * Partial problems (a page whose extraction failed) do not fail the document;
810
+ * they are listed in `gaps`. `stored` is not strictly final: RDF arriving later
811
+ * moves the document back to `extracting` until it is bundled too.
758
812
  */
759
813
  export type DocumentProcessingStage = 'uploaded' | 'processing' | 'extracting' | 'stored' | 'failed';
814
+ /** How many of a project's documents are in each stage. */
815
+ export type DocumentStageCounts = Record<DocumentProcessingStage, number>;
760
816
  /** Per-document pipeline progress for one uploaded file. */
761
817
  export interface DocumentProgress {
762
818
  documentUUID: string;
@@ -776,12 +832,16 @@ export interface DocumentProgress {
776
832
  contributors: string[];
777
833
  rdfCount: number;
778
834
  rdfStoredCount: number;
835
+ /** What was missing when the document went ready, e.g. `extraction failed: 2`. */
836
+ gaps?: string[];
779
837
  error?: string;
780
838
  }
781
839
  /** Counts-only per-project rollup, streamed by {@link CueProcessingApi.watchMyStatus}. */
782
840
  export interface ProjectProcessingSummary {
783
841
  projectId: string;
784
842
  stage: ProcessingStage;
843
+ /** Absent on older servers. */
844
+ documentCounts?: DocumentStageCounts;
785
845
  pendingDocumentCount: number;
786
846
  failedDocumentCount: number;
787
847
  lastActivityAt?: string;
@@ -802,10 +862,98 @@ export interface MyProcessingStatus {
802
862
  */
803
863
  truncated?: boolean;
804
864
  }
865
+ /** Options for `CueApi.reprocessDocument` — mirrors the service's `ReprocessDocumentDto`. */
866
+ export interface ReprocessDocumentOptions {
867
+ removeGraphs?: boolean;
868
+ removeProcessed?: boolean;
869
+ /** Publish even when the raw blob carries `skip_processing` (does not clear the flag). */
870
+ force?: boolean;
871
+ resetAttempts?: boolean;
872
+ dryRun?: boolean;
873
+ }
874
+ /** 202 body: the reprocess is running, follow `processId` on the status socket. */
875
+ export interface ReprocessAccepted {
876
+ processId: string;
877
+ projectId: string;
878
+ documentUUID: string;
879
+ status: string;
880
+ }
881
+ /** 200 body for a `dryRun` request — what a real run would purge. */
882
+ export interface ReprocessPlan {
883
+ dryRun: true;
884
+ projectId: string;
885
+ documentUUID: string;
886
+ graphs: string[];
887
+ quads: number;
888
+ blobs: string[];
889
+ rawBlobPresent: boolean;
890
+ /**
891
+ * Count of this document's mentions already resolved into a canonical entity
892
+ * elsewhere in the project — purging leaves that entity's link dangling until
893
+ * the pipeline re-resolves the same text.
894
+ */
895
+ resolvedMentionsAtRisk: number;
896
+ }
897
+ export declare const isReprocessPlan: (r: ReprocessAccepted | ReprocessPlan) => r is ReprocessPlan;
898
+ /** One entity mention to create — mirrors the service's `CreateEntityMentionDto`. */
899
+ export interface EntityMentionInput {
900
+ mention: {
901
+ iri: string;
902
+ value: string;
903
+ entityCategories: string[];
904
+ description?: string | null;
905
+ resolvesTo?: string | null;
906
+ properties?: string[];
907
+ /** Subjects (e.g. selectors) this mention is made in. */
908
+ mentions?: string[];
909
+ relationships?: {
910
+ predicate: string;
911
+ objectIri: string;
912
+ }[];
913
+ };
914
+ namedGraph: string;
915
+ comment?: string;
916
+ }
917
+ /** One entity mention to delete — mirrors the service's `DeleteEntityMentionDto`. */
918
+ export interface EntityMentionDeletion {
919
+ iri: string;
920
+ comment?: string;
921
+ }
922
+ /** One selector to create — mirrors the service's `CreateSelectorDto`. */
923
+ export interface SelectorInput {
924
+ iri: string;
925
+ type: string;
926
+ selectorSubjects: string[];
927
+ selectorObject: string;
928
+ value: string;
929
+ namedGraph: string;
930
+ comment?: string;
931
+ }
932
+ /** Replaces a subject's content categories — mirrors the service's `ChangeObjectIRIRequestDto`. */
933
+ export interface ContentCategoryChange {
934
+ subject: string;
935
+ existingValues: string[];
936
+ newValues: string[];
937
+ comment?: string;
938
+ }
939
+ /** Outcome of one graph edit — mirrors the service's `MutationResult`. */
940
+ export interface EditResult {
941
+ message: string;
942
+ success: boolean;
943
+ insertCount?: number;
944
+ iri?: string;
945
+ errorCode?: string;
946
+ }
947
+ /** Outcome of a batch of graph edits — mirrors the service's `BatchMutationResult`. */
948
+ export interface BatchEditResult {
949
+ results: EditResult[];
950
+ successCount: number;
951
+ failureCount: number;
952
+ }
805
953
  /** Lifecycle of a superadmin document-reprocess request. */
806
954
  export type ReprocessJobStatus = 'queued' | 'purging-rdf' | 'purging-blobs' | 'publishing' | 'succeeded' | 'failed';
807
955
  /**
808
- * Progress of one document reprocess (`POST /commands/document/:uuid/reprocess`),
956
+ * Progress of one document reprocess (`POST /bff/document/:uuid/reprocess`),
809
957
  * pushed on the same socket as the rest of the pipeline status.
810
958
  */
811
959
  export interface DocumentReprocessJob {
@@ -827,7 +975,7 @@ export interface DocumentReprocessJob {
827
975
  finishedAt?: string;
828
976
  }
829
977
  /**
830
- * Aggregated, per-project pipeline status pushed live by the `accessors-data-views`
978
+ * Aggregated, per-project pipeline status pushed live by the `writers-cue-bff`
831
979
  * processing-status WebSocket (see `CueProcessingApi.watchStatus`). Shape mirrors
832
980
  * `cue-ui`'s `ProcessingStatus` (views/project-settings/models.ts) so it can be
833
981
  * passed straight through to `<cue-project-settings>` / `<cue-portal-upload>`.
@@ -857,9 +1005,11 @@ export interface ProcessingStatus {
857
1005
  * this as "the recent ones" and rely on the counts below for totals.
858
1006
  */
859
1007
  documents?: DocumentProgress[];
1008
+ /** How many documents are in each stage. Exact. Absent on older servers. */
1009
+ documentCounts?: DocumentStageCounts;
860
1010
  /**
861
1011
  * Documents not yet in a terminal stage. Exact even when `documents` was
862
- * truncated. Optional because a client may be talking to a data-views
1012
+ * truncated. Optional because a client may be talking to a writers-cue-bff
863
1013
  * deployment predating per-document tracking, which omits it — treat absent as
864
1014
  * "unknown", not zero.
865
1015
  */
@@ -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;
@@ -46,6 +49,39 @@ export declare class CueProfile {
46
49
  listOrganizations(): Promise<(Pick<OrganizationData, 'id' | 'name'> & {
47
50
  isAdmin: boolean;
48
51
  })[]>;
52
+ /**
53
+ * Creates an organisation with the current user as its admin — for a user
54
+ * who belongs to none. It claims the user's email domain when that email is
55
+ * verified, not a free-mail provider and not claimed already; otherwise it is
56
+ * created without a domain. Throws `CueRequestError` with `code`
57
+ * 'alreadyInOrganisation' when the user already belongs to one.
58
+ */
59
+ createOwnOrganization(orgName: string, plan: OrgSignUpPlan): Promise<{
60
+ orgId: string;
61
+ orgName: string;
62
+ domains: string[];
63
+ checkoutUrl?: string;
64
+ }>;
65
+ /**
66
+ * Asks to join the organisation owning `domain` (e.g. `qaecy.com`); its
67
+ * admins get an email. Resolves the same whether or not any organisation
68
+ * owns the domain, so it can't be used to find out. Throws `CueRequestError`
69
+ * with `code` 'emailNotVerified' | 'invalidDomain'.
70
+ */
71
+ requestToJoinOrganization(domain: string): Promise<void>;
72
+ /**
73
+ * Joins the organisation owning the current user's email domain — only once
74
+ * that email is verified, which is why sign-up itself never joins one. Call
75
+ * it when a signed-in user has no organisation; `joined` is false when the
76
+ * email is unverified or no organisation owns the domain.
77
+ */
78
+ joinOrganizationByEmailDomain(): Promise<{
79
+ joined: boolean;
80
+ orgId?: string;
81
+ orgName?: string;
82
+ }>;
83
+ /** POSTs JSON and surfaces the backend's error `code`, for calls whose failures a UI maps. */
84
+ private _fetchCoded;
49
85
  /** Returns all members of the given organisation. Caller must be an org admin or superadmin. */
50
86
  getOrgMembers(orgId: string): Promise<OrgMember[]>;
51
87
  /** Returns just the given organisation's admins. Caller must be a member (or admin/superadmin). */
@@ -1,4 +1,4 @@
1
- import { EntityCategory, ProjectSchema } from '../../models/src/index';
1
+ import { ContentCategory, EntityCategory, ProjectSchema } from '../../models/src/index';
2
2
  import { CueAuth } from './auth';
3
3
  export interface MutationResult {
4
4
  message: string;
@@ -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.
@@ -114,10 +145,21 @@ export declare class CueSemanticTemplate {
114
145
  * starting point — the same list for every caller, nothing project-specific about it.
115
146
  */
116
147
  getDefaultEntities(projectId: string): Promise<EntityCategory[]>;
148
+ /**
149
+ * The QAECY catalogues' content categories — the document types a term can be limited to —
150
+ * with pinned IRIs stripped, so each is referenced by its bare `key`. The same list for every
151
+ * caller.
152
+ */
153
+ getDefaultContentCategories(projectId: string): Promise<ContentCategory[]>;
117
154
  /** Re-pushes the project's currently stored template into its `databases-cue` schema graph, without mutating it. */
118
155
  reloadSchema(projectId: string): Promise<MutationResult>;
119
156
  private _get;
120
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>;
121
163
  private _post;
122
164
  private _delete;
123
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;