filecheck-node 0.2.0 → 0.3.0
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/dist/index.cjs +184 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +162 -17
- package/dist/index.d.ts +162 -17
- package/dist/index.js +184 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -321,7 +321,7 @@ declare const webhooks: {
|
|
|
321
321
|
* resources.
|
|
322
322
|
*/
|
|
323
323
|
interface HttpRequest {
|
|
324
|
-
method: 'GET' | 'POST' | 'DELETE';
|
|
324
|
+
method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
325
325
|
url: string;
|
|
326
326
|
headers: Record<string, string>;
|
|
327
327
|
/** JSON string, multipart form data, or nothing. */
|
|
@@ -356,6 +356,7 @@ type FetchLike = (url: string, init: {
|
|
|
356
356
|
text(): Promise<string>;
|
|
357
357
|
}>;
|
|
358
358
|
|
|
359
|
+
type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
359
360
|
interface RequestOptions {
|
|
360
361
|
query?: Record<string, string | number | boolean | undefined>;
|
|
361
362
|
body?: unknown;
|
|
@@ -370,9 +371,9 @@ declare class Requestor {
|
|
|
370
371
|
private readonly timeoutMs;
|
|
371
372
|
private readonly maxRetries;
|
|
372
373
|
constructor(transport: HttpTransport, baseUrl: string, secretKey: string, timeoutMs: number, maxRetries: number);
|
|
373
|
-
raw(method:
|
|
374
|
+
raw(method: HttpMethod, path: string, options?: RequestOptions): Promise<HttpResponse>;
|
|
374
375
|
/** Request + parse. Throws a typed FilecheckError on any non-2xx. */
|
|
375
|
-
json<T>(method:
|
|
376
|
+
json<T>(method: HttpMethod, path: string, options?: RequestOptions): Promise<{
|
|
376
377
|
status: number;
|
|
377
378
|
data: T;
|
|
378
379
|
}>;
|
|
@@ -443,10 +444,18 @@ interface JobContext {
|
|
|
443
444
|
min_mm?: number;
|
|
444
445
|
};
|
|
445
446
|
}
|
|
446
|
-
/** `POST /jobs`.
|
|
447
|
+
/** `POST /jobs`. */
|
|
447
448
|
interface CreateJobParams {
|
|
448
449
|
sources: CreateJobSource[];
|
|
449
450
|
ruleId?: string;
|
|
451
|
+
/**
|
|
452
|
+
* Run the files through a workflow's intake (`wf_…`), as the storefront does
|
|
453
|
+
* for a product mapped to it: its rule replaces `ruleId` and `sources[].steps`.
|
|
454
|
+
* Drafts work too, so a workflow can be tried before it is published.
|
|
455
|
+
*/
|
|
456
|
+
workflowId?: string;
|
|
457
|
+
/** An unsaved workflow record to run the files through (kept a day, then discarded). */
|
|
458
|
+
previewWorkflow?: Record<string, unknown>;
|
|
450
459
|
channel?: 'api' | 'store' | 'admin';
|
|
451
460
|
customerId?: string;
|
|
452
461
|
orderId?: string;
|
|
@@ -622,28 +631,84 @@ declare class JobsResource {
|
|
|
622
631
|
}
|
|
623
632
|
|
|
624
633
|
/**
|
|
625
|
-
*
|
|
626
|
-
* (`'domain'` rows shadow same-id `'store'` rows), payloads are
|
|
634
|
+
* A record from one of the setup collections. Beyond `id`, `enabled`, and
|
|
635
|
+
* `source` (`'domain'` rows shadow same-id `'store'` rows), payloads are
|
|
636
|
+
* free-form: the API's JSON schemas describe them.
|
|
627
637
|
*/
|
|
628
638
|
interface LibraryItem {
|
|
629
639
|
id: string;
|
|
630
640
|
enabled?: boolean;
|
|
631
641
|
source?: 'domain' | 'store';
|
|
642
|
+
draft?: boolean;
|
|
643
|
+
customized?: boolean;
|
|
644
|
+
[key: string]: unknown;
|
|
645
|
+
}
|
|
646
|
+
/** What a write answers: the record as saved (or as it would be, with `dryRun`). */
|
|
647
|
+
interface WriteResult<T = LibraryItem> {
|
|
648
|
+
record: T;
|
|
649
|
+
/** True when nothing was saved (`dryRun: true` was sent). */
|
|
650
|
+
dryRun?: boolean;
|
|
651
|
+
}
|
|
652
|
+
/** `publish()`: the record, live now, and every id published with it (drafts it pointed at come first). */
|
|
653
|
+
interface PublishResult extends WriteResult {
|
|
654
|
+
published: string[];
|
|
655
|
+
}
|
|
656
|
+
/** `revert()`: the catalog record that applies again, and whether there was a copy to drop. */
|
|
657
|
+
interface RevertResult extends WriteResult {
|
|
658
|
+
reverted: boolean;
|
|
659
|
+
}
|
|
660
|
+
/** `del()`: `{ id, deleted: true }`. */
|
|
661
|
+
interface DeletedRecord {
|
|
662
|
+
id?: string;
|
|
663
|
+
deleted: true;
|
|
632
664
|
[key: string]: unknown;
|
|
633
665
|
}
|
|
666
|
+
interface CreateOptions {
|
|
667
|
+
/** Save as a draft: hidden from the storefront and dashboard until published; jobs can still run against it by id. */
|
|
668
|
+
draft?: boolean;
|
|
669
|
+
/** Validate and check references without saving. */
|
|
670
|
+
dryRun?: boolean;
|
|
671
|
+
}
|
|
672
|
+
interface UpdateOptions {
|
|
673
|
+
/** Validate and check references without saving. */
|
|
674
|
+
dryRun?: boolean;
|
|
675
|
+
}
|
|
634
676
|
/**
|
|
635
|
-
*
|
|
636
|
-
*
|
|
637
|
-
*
|
|
677
|
+
* List / get / create / update (JSON Merge Patch) / delete over one API
|
|
678
|
+
* collection. Envelope keys differ per resource (and are not always the path
|
|
679
|
+
* name — optimize-presets uses `presets`).
|
|
638
680
|
*/
|
|
639
|
-
declare class
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
681
|
+
declare class RecordResource<T = LibraryItem> {
|
|
682
|
+
protected readonly requestor: Requestor;
|
|
683
|
+
protected readonly path: string;
|
|
684
|
+
protected readonly listKey: string;
|
|
685
|
+
protected readonly itemKey: string;
|
|
644
686
|
constructor(requestor: Requestor, path: string, listKey: string, itemKey: string);
|
|
645
|
-
|
|
646
|
-
|
|
687
|
+
protected url(id: string, suffix?: string): string;
|
|
688
|
+
protected listWith(query?: Record<string, string | undefined>): Promise<T[]>;
|
|
689
|
+
protected toResult<R extends WriteResult<T>>(data: Record<string, unknown>): R;
|
|
690
|
+
list(): Promise<T[]>;
|
|
691
|
+
retrieve(id: string): Promise<T>;
|
|
692
|
+
create(record: Record<string, unknown>, options?: UpdateOptions): Promise<WriteResult<T>>;
|
|
693
|
+
/** A JSON Merge Patch (RFC 7396): send only what changes; `null` removes a key; arrays replace. */
|
|
694
|
+
update(id: string, patch: Record<string, unknown>, options?: UpdateOptions): Promise<WriteResult<T>>;
|
|
695
|
+
del(id: string): Promise<DeletedRecord>;
|
|
696
|
+
}
|
|
697
|
+
/**
|
|
698
|
+
* The catalog collections — workflows, rules, profiles, connectors, optimize
|
|
699
|
+
* presets: your records merged with the built-in catalog, copy-on-write
|
|
700
|
+
* customisation, drafts.
|
|
701
|
+
*/
|
|
702
|
+
declare class LibraryResource extends RecordResource<LibraryItem> {
|
|
703
|
+
/** `drafts: true` includes your unpublished drafts (marked `draft: true`). */
|
|
704
|
+
list(options?: {
|
|
705
|
+
drafts?: boolean;
|
|
706
|
+
}): Promise<LibraryItem[]>;
|
|
707
|
+
create(record: Record<string, unknown>, options?: CreateOptions): Promise<WriteResult>;
|
|
708
|
+
/** Makes a draft live, with the drafts it points at. */
|
|
709
|
+
publish(id: string): Promise<PublishResult>;
|
|
710
|
+
/** Drops your copy of a catalog record (or un-hides one you deleted). */
|
|
711
|
+
revert(id: string): Promise<RevertResult>;
|
|
647
712
|
}
|
|
648
713
|
|
|
649
714
|
declare class OrdersResource {
|
|
@@ -653,6 +718,80 @@ declare class OrdersResource {
|
|
|
653
718
|
create(orderId: string, params: Record<string, unknown>): Promise<OrderResult>;
|
|
654
719
|
}
|
|
655
720
|
|
|
721
|
+
/** A record whose shape the API's JSON schema describes (destination, webhook, settings…). */
|
|
722
|
+
type SetupRecord = Record<string, unknown> & {
|
|
723
|
+
id?: string;
|
|
724
|
+
};
|
|
725
|
+
/** `POST …/{id}/test`: whether the sample delivery got through. */
|
|
726
|
+
interface TestResult {
|
|
727
|
+
ok: boolean;
|
|
728
|
+
[key: string]: unknown;
|
|
729
|
+
}
|
|
730
|
+
/**
|
|
731
|
+
* Delivery destinations: SFTP / FTP hotfolders, S3, webhooks, email. Secret
|
|
732
|
+
* params are write-only and read back as `********`.
|
|
733
|
+
*/
|
|
734
|
+
declare class DestinationsResource extends RecordResource<SetupRecord> {
|
|
735
|
+
constructor(requestor: Requestor);
|
|
736
|
+
/**
|
|
737
|
+
* Delivers a sample order (TEST-1001, one-page Sample_Product.pdf) through
|
|
738
|
+
* the real transport. Hotfolders really receive the file.
|
|
739
|
+
*/
|
|
740
|
+
test(id: string): Promise<TestResult>;
|
|
741
|
+
}
|
|
742
|
+
/** HTTP callbacks for job, proof, account and billing events. */
|
|
743
|
+
declare class WebhooksResource extends RecordResource<SetupRecord> {
|
|
744
|
+
constructor(requestor: Requestor);
|
|
745
|
+
/** The event types a webhook can subscribe to. */
|
|
746
|
+
events(): Promise<SetupRecord[]>;
|
|
747
|
+
/** Sends a signed test event to the webhook's URL. */
|
|
748
|
+
test(id: string): Promise<TestResult>;
|
|
749
|
+
}
|
|
750
|
+
interface ProductMap {
|
|
751
|
+
productId: string;
|
|
752
|
+
workflowId?: string | null;
|
|
753
|
+
title?: string;
|
|
754
|
+
url?: string | null;
|
|
755
|
+
[key: string]: unknown;
|
|
756
|
+
}
|
|
757
|
+
/** Which workflow each product in the store opens. */
|
|
758
|
+
declare class ProductMapsResource {
|
|
759
|
+
private readonly requestor;
|
|
760
|
+
constructor(requestor: Requestor);
|
|
761
|
+
list(): Promise<ProductMap[]>;
|
|
762
|
+
/** Maps a product (Shopify: its numeric id) to a published workflow. */
|
|
763
|
+
set(productId: string, map: Record<string, unknown>, options?: UpdateOptions): Promise<{
|
|
764
|
+
record: ProductMap;
|
|
765
|
+
dryRun?: boolean;
|
|
766
|
+
}>;
|
|
767
|
+
del(productId: string): Promise<DeletedRecord>;
|
|
768
|
+
}
|
|
769
|
+
interface StoreProductPage {
|
|
770
|
+
products: SetupRecord[];
|
|
771
|
+
hasMore: boolean;
|
|
772
|
+
nextCursor: string | null;
|
|
773
|
+
}
|
|
774
|
+
/** Products in the connected store (Shopify), each with the workflow it is mapped to. */
|
|
775
|
+
declare class ProductsResource {
|
|
776
|
+
private readonly requestor;
|
|
777
|
+
constructor(requestor: Requestor);
|
|
778
|
+
search(params?: {
|
|
779
|
+
search?: string;
|
|
780
|
+
cursor?: string;
|
|
781
|
+
}): Promise<StoreProductPage>;
|
|
782
|
+
}
|
|
783
|
+
/** How the storefront Element appears on product pages. */
|
|
784
|
+
declare class SettingsResource {
|
|
785
|
+
private readonly requestor;
|
|
786
|
+
constructor(requestor: Requestor);
|
|
787
|
+
retrieve(): Promise<SetupRecord>;
|
|
788
|
+
/** Send only what changes; `null` puts a setting back to its default. */
|
|
789
|
+
update(patch: Record<string, unknown>, options?: UpdateOptions): Promise<{
|
|
790
|
+
record: SetupRecord;
|
|
791
|
+
dryRun?: boolean;
|
|
792
|
+
}>;
|
|
793
|
+
}
|
|
794
|
+
|
|
656
795
|
type UploadInput = Blob | ArrayBuffer | ArrayBufferView | Buffer;
|
|
657
796
|
interface UploadOptions {
|
|
658
797
|
mimeType?: string;
|
|
@@ -699,6 +838,12 @@ declare class Filecheck {
|
|
|
699
838
|
readonly rules: LibraryResource;
|
|
700
839
|
readonly profiles: LibraryResource;
|
|
701
840
|
readonly optimizePresets: LibraryResource;
|
|
841
|
+
readonly destinations: DestinationsResource;
|
|
842
|
+
readonly productMaps: ProductMapsResource;
|
|
843
|
+
readonly products: ProductsResource;
|
|
844
|
+
readonly settings: SettingsResource;
|
|
845
|
+
/** Webhook endpoints (`/webhooks`). `webhooks` is the signature-verification helper. */
|
|
846
|
+
readonly webhookEndpoints: WebhooksResource;
|
|
702
847
|
readonly webhooks: {
|
|
703
848
|
constructEvent: typeof constructEvent;
|
|
704
849
|
computeSignature: typeof computeSignature;
|
|
@@ -749,4 +894,4 @@ declare class ConnectionError extends FilecheckError {
|
|
|
749
894
|
declare class WebhookSignatureError extends FilecheckError {
|
|
750
895
|
}
|
|
751
896
|
|
|
752
|
-
export { APIError, type Artifact, AuthenticationError, ConnectionError, type ConstructEventOptions, type CreateJobParams, type CreateJobSource, type DeleteJobResult, type FetchLike, type FileType, Filecheck, type FilecheckClientOptions, FilecheckError, type FixParams, type FixSource, type HttpRequest, type HttpResponse, type HttpTransport, InvalidRequestError, type Job, type JobCompletedPayload, type JobContext, type JobCreatedPayload, type JobPage, type JobResult, type JobRuns, type JobStatus, type JobStepInput, type JobSummary, type LibraryItem, type ListJobsParams, NotFoundError, type OnFailPolicy, type OptimizeParams, type OptimizeResult, type OptimizeSource, type OrderResult, type Outcome, type PreflightParams, type PreflightResult, type PreflightSource, type PreviewsParams, type PreviewsSource, RateLimitError, type Run, type SourceRef, type Step, type StepType, TERMINAL_STATUSES, type Task, type UploadInput, type UploadOptions, type UploadResult, type ValidateParams, type ValidateProfileCode, type ValidateProfileResult, type ValidateResult, type ValidateSource, type VerifyOptions, type VerifyReason, type VerifyResult, type VerifyState, type WaitOptions, type WebhookEvent, type WebhookParam, WebhookSignatureError, computeSignature, constructEvent, Filecheck as default, isTerminal, maskKey, resolveVerify, webhooks };
|
|
897
|
+
export { APIError, type Artifact, AuthenticationError, ConnectionError, type ConstructEventOptions, type CreateJobParams, type CreateJobSource, type CreateOptions, type DeleteJobResult, type DeletedRecord, DestinationsResource, type FetchLike, type FileType, Filecheck, type FilecheckClientOptions, FilecheckError, type FixParams, type FixSource, type HttpRequest, type HttpResponse, type HttpTransport, InvalidRequestError, type Job, type JobCompletedPayload, type JobContext, type JobCreatedPayload, type JobPage, type JobResult, type JobRuns, type JobStatus, type JobStepInput, type JobSummary, type LibraryItem, LibraryResource, type ListJobsParams, NotFoundError, type OnFailPolicy, type OptimizeParams, type OptimizeResult, type OptimizeSource, type OrderResult, type Outcome, type PreflightParams, type PreflightResult, type PreflightSource, type PreviewsParams, type PreviewsSource, type ProductMap, ProductMapsResource, ProductsResource, type PublishResult, RateLimitError, RecordResource, type RevertResult, type Run, SettingsResource, type SetupRecord, type SourceRef, type Step, type StepType, type StoreProductPage, TERMINAL_STATUSES, type Task, type TestResult, type UpdateOptions, type UploadInput, type UploadOptions, type UploadResult, type ValidateParams, type ValidateProfileCode, type ValidateProfileResult, type ValidateResult, type ValidateSource, type VerifyOptions, type VerifyReason, type VerifyResult, type VerifyState, type WaitOptions, type WebhookEvent, type WebhookParam, WebhookSignatureError, WebhooksResource, type WriteResult, computeSignature, constructEvent, Filecheck as default, isTerminal, maskKey, resolveVerify, webhooks };
|
package/dist/index.d.ts
CHANGED
|
@@ -321,7 +321,7 @@ declare const webhooks: {
|
|
|
321
321
|
* resources.
|
|
322
322
|
*/
|
|
323
323
|
interface HttpRequest {
|
|
324
|
-
method: 'GET' | 'POST' | 'DELETE';
|
|
324
|
+
method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
325
325
|
url: string;
|
|
326
326
|
headers: Record<string, string>;
|
|
327
327
|
/** JSON string, multipart form data, or nothing. */
|
|
@@ -356,6 +356,7 @@ type FetchLike = (url: string, init: {
|
|
|
356
356
|
text(): Promise<string>;
|
|
357
357
|
}>;
|
|
358
358
|
|
|
359
|
+
type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
359
360
|
interface RequestOptions {
|
|
360
361
|
query?: Record<string, string | number | boolean | undefined>;
|
|
361
362
|
body?: unknown;
|
|
@@ -370,9 +371,9 @@ declare class Requestor {
|
|
|
370
371
|
private readonly timeoutMs;
|
|
371
372
|
private readonly maxRetries;
|
|
372
373
|
constructor(transport: HttpTransport, baseUrl: string, secretKey: string, timeoutMs: number, maxRetries: number);
|
|
373
|
-
raw(method:
|
|
374
|
+
raw(method: HttpMethod, path: string, options?: RequestOptions): Promise<HttpResponse>;
|
|
374
375
|
/** Request + parse. Throws a typed FilecheckError on any non-2xx. */
|
|
375
|
-
json<T>(method:
|
|
376
|
+
json<T>(method: HttpMethod, path: string, options?: RequestOptions): Promise<{
|
|
376
377
|
status: number;
|
|
377
378
|
data: T;
|
|
378
379
|
}>;
|
|
@@ -443,10 +444,18 @@ interface JobContext {
|
|
|
443
444
|
min_mm?: number;
|
|
444
445
|
};
|
|
445
446
|
}
|
|
446
|
-
/** `POST /jobs`.
|
|
447
|
+
/** `POST /jobs`. */
|
|
447
448
|
interface CreateJobParams {
|
|
448
449
|
sources: CreateJobSource[];
|
|
449
450
|
ruleId?: string;
|
|
451
|
+
/**
|
|
452
|
+
* Run the files through a workflow's intake (`wf_…`), as the storefront does
|
|
453
|
+
* for a product mapped to it: its rule replaces `ruleId` and `sources[].steps`.
|
|
454
|
+
* Drafts work too, so a workflow can be tried before it is published.
|
|
455
|
+
*/
|
|
456
|
+
workflowId?: string;
|
|
457
|
+
/** An unsaved workflow record to run the files through (kept a day, then discarded). */
|
|
458
|
+
previewWorkflow?: Record<string, unknown>;
|
|
450
459
|
channel?: 'api' | 'store' | 'admin';
|
|
451
460
|
customerId?: string;
|
|
452
461
|
orderId?: string;
|
|
@@ -622,28 +631,84 @@ declare class JobsResource {
|
|
|
622
631
|
}
|
|
623
632
|
|
|
624
633
|
/**
|
|
625
|
-
*
|
|
626
|
-
* (`'domain'` rows shadow same-id `'store'` rows), payloads are
|
|
634
|
+
* A record from one of the setup collections. Beyond `id`, `enabled`, and
|
|
635
|
+
* `source` (`'domain'` rows shadow same-id `'store'` rows), payloads are
|
|
636
|
+
* free-form: the API's JSON schemas describe them.
|
|
627
637
|
*/
|
|
628
638
|
interface LibraryItem {
|
|
629
639
|
id: string;
|
|
630
640
|
enabled?: boolean;
|
|
631
641
|
source?: 'domain' | 'store';
|
|
642
|
+
draft?: boolean;
|
|
643
|
+
customized?: boolean;
|
|
644
|
+
[key: string]: unknown;
|
|
645
|
+
}
|
|
646
|
+
/** What a write answers: the record as saved (or as it would be, with `dryRun`). */
|
|
647
|
+
interface WriteResult<T = LibraryItem> {
|
|
648
|
+
record: T;
|
|
649
|
+
/** True when nothing was saved (`dryRun: true` was sent). */
|
|
650
|
+
dryRun?: boolean;
|
|
651
|
+
}
|
|
652
|
+
/** `publish()`: the record, live now, and every id published with it (drafts it pointed at come first). */
|
|
653
|
+
interface PublishResult extends WriteResult {
|
|
654
|
+
published: string[];
|
|
655
|
+
}
|
|
656
|
+
/** `revert()`: the catalog record that applies again, and whether there was a copy to drop. */
|
|
657
|
+
interface RevertResult extends WriteResult {
|
|
658
|
+
reverted: boolean;
|
|
659
|
+
}
|
|
660
|
+
/** `del()`: `{ id, deleted: true }`. */
|
|
661
|
+
interface DeletedRecord {
|
|
662
|
+
id?: string;
|
|
663
|
+
deleted: true;
|
|
632
664
|
[key: string]: unknown;
|
|
633
665
|
}
|
|
666
|
+
interface CreateOptions {
|
|
667
|
+
/** Save as a draft: hidden from the storefront and dashboard until published; jobs can still run against it by id. */
|
|
668
|
+
draft?: boolean;
|
|
669
|
+
/** Validate and check references without saving. */
|
|
670
|
+
dryRun?: boolean;
|
|
671
|
+
}
|
|
672
|
+
interface UpdateOptions {
|
|
673
|
+
/** Validate and check references without saving. */
|
|
674
|
+
dryRun?: boolean;
|
|
675
|
+
}
|
|
634
676
|
/**
|
|
635
|
-
*
|
|
636
|
-
*
|
|
637
|
-
*
|
|
677
|
+
* List / get / create / update (JSON Merge Patch) / delete over one API
|
|
678
|
+
* collection. Envelope keys differ per resource (and are not always the path
|
|
679
|
+
* name — optimize-presets uses `presets`).
|
|
638
680
|
*/
|
|
639
|
-
declare class
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
681
|
+
declare class RecordResource<T = LibraryItem> {
|
|
682
|
+
protected readonly requestor: Requestor;
|
|
683
|
+
protected readonly path: string;
|
|
684
|
+
protected readonly listKey: string;
|
|
685
|
+
protected readonly itemKey: string;
|
|
644
686
|
constructor(requestor: Requestor, path: string, listKey: string, itemKey: string);
|
|
645
|
-
|
|
646
|
-
|
|
687
|
+
protected url(id: string, suffix?: string): string;
|
|
688
|
+
protected listWith(query?: Record<string, string | undefined>): Promise<T[]>;
|
|
689
|
+
protected toResult<R extends WriteResult<T>>(data: Record<string, unknown>): R;
|
|
690
|
+
list(): Promise<T[]>;
|
|
691
|
+
retrieve(id: string): Promise<T>;
|
|
692
|
+
create(record: Record<string, unknown>, options?: UpdateOptions): Promise<WriteResult<T>>;
|
|
693
|
+
/** A JSON Merge Patch (RFC 7396): send only what changes; `null` removes a key; arrays replace. */
|
|
694
|
+
update(id: string, patch: Record<string, unknown>, options?: UpdateOptions): Promise<WriteResult<T>>;
|
|
695
|
+
del(id: string): Promise<DeletedRecord>;
|
|
696
|
+
}
|
|
697
|
+
/**
|
|
698
|
+
* The catalog collections — workflows, rules, profiles, connectors, optimize
|
|
699
|
+
* presets: your records merged with the built-in catalog, copy-on-write
|
|
700
|
+
* customisation, drafts.
|
|
701
|
+
*/
|
|
702
|
+
declare class LibraryResource extends RecordResource<LibraryItem> {
|
|
703
|
+
/** `drafts: true` includes your unpublished drafts (marked `draft: true`). */
|
|
704
|
+
list(options?: {
|
|
705
|
+
drafts?: boolean;
|
|
706
|
+
}): Promise<LibraryItem[]>;
|
|
707
|
+
create(record: Record<string, unknown>, options?: CreateOptions): Promise<WriteResult>;
|
|
708
|
+
/** Makes a draft live, with the drafts it points at. */
|
|
709
|
+
publish(id: string): Promise<PublishResult>;
|
|
710
|
+
/** Drops your copy of a catalog record (or un-hides one you deleted). */
|
|
711
|
+
revert(id: string): Promise<RevertResult>;
|
|
647
712
|
}
|
|
648
713
|
|
|
649
714
|
declare class OrdersResource {
|
|
@@ -653,6 +718,80 @@ declare class OrdersResource {
|
|
|
653
718
|
create(orderId: string, params: Record<string, unknown>): Promise<OrderResult>;
|
|
654
719
|
}
|
|
655
720
|
|
|
721
|
+
/** A record whose shape the API's JSON schema describes (destination, webhook, settings…). */
|
|
722
|
+
type SetupRecord = Record<string, unknown> & {
|
|
723
|
+
id?: string;
|
|
724
|
+
};
|
|
725
|
+
/** `POST …/{id}/test`: whether the sample delivery got through. */
|
|
726
|
+
interface TestResult {
|
|
727
|
+
ok: boolean;
|
|
728
|
+
[key: string]: unknown;
|
|
729
|
+
}
|
|
730
|
+
/**
|
|
731
|
+
* Delivery destinations: SFTP / FTP hotfolders, S3, webhooks, email. Secret
|
|
732
|
+
* params are write-only and read back as `********`.
|
|
733
|
+
*/
|
|
734
|
+
declare class DestinationsResource extends RecordResource<SetupRecord> {
|
|
735
|
+
constructor(requestor: Requestor);
|
|
736
|
+
/**
|
|
737
|
+
* Delivers a sample order (TEST-1001, one-page Sample_Product.pdf) through
|
|
738
|
+
* the real transport. Hotfolders really receive the file.
|
|
739
|
+
*/
|
|
740
|
+
test(id: string): Promise<TestResult>;
|
|
741
|
+
}
|
|
742
|
+
/** HTTP callbacks for job, proof, account and billing events. */
|
|
743
|
+
declare class WebhooksResource extends RecordResource<SetupRecord> {
|
|
744
|
+
constructor(requestor: Requestor);
|
|
745
|
+
/** The event types a webhook can subscribe to. */
|
|
746
|
+
events(): Promise<SetupRecord[]>;
|
|
747
|
+
/** Sends a signed test event to the webhook's URL. */
|
|
748
|
+
test(id: string): Promise<TestResult>;
|
|
749
|
+
}
|
|
750
|
+
interface ProductMap {
|
|
751
|
+
productId: string;
|
|
752
|
+
workflowId?: string | null;
|
|
753
|
+
title?: string;
|
|
754
|
+
url?: string | null;
|
|
755
|
+
[key: string]: unknown;
|
|
756
|
+
}
|
|
757
|
+
/** Which workflow each product in the store opens. */
|
|
758
|
+
declare class ProductMapsResource {
|
|
759
|
+
private readonly requestor;
|
|
760
|
+
constructor(requestor: Requestor);
|
|
761
|
+
list(): Promise<ProductMap[]>;
|
|
762
|
+
/** Maps a product (Shopify: its numeric id) to a published workflow. */
|
|
763
|
+
set(productId: string, map: Record<string, unknown>, options?: UpdateOptions): Promise<{
|
|
764
|
+
record: ProductMap;
|
|
765
|
+
dryRun?: boolean;
|
|
766
|
+
}>;
|
|
767
|
+
del(productId: string): Promise<DeletedRecord>;
|
|
768
|
+
}
|
|
769
|
+
interface StoreProductPage {
|
|
770
|
+
products: SetupRecord[];
|
|
771
|
+
hasMore: boolean;
|
|
772
|
+
nextCursor: string | null;
|
|
773
|
+
}
|
|
774
|
+
/** Products in the connected store (Shopify), each with the workflow it is mapped to. */
|
|
775
|
+
declare class ProductsResource {
|
|
776
|
+
private readonly requestor;
|
|
777
|
+
constructor(requestor: Requestor);
|
|
778
|
+
search(params?: {
|
|
779
|
+
search?: string;
|
|
780
|
+
cursor?: string;
|
|
781
|
+
}): Promise<StoreProductPage>;
|
|
782
|
+
}
|
|
783
|
+
/** How the storefront Element appears on product pages. */
|
|
784
|
+
declare class SettingsResource {
|
|
785
|
+
private readonly requestor;
|
|
786
|
+
constructor(requestor: Requestor);
|
|
787
|
+
retrieve(): Promise<SetupRecord>;
|
|
788
|
+
/** Send only what changes; `null` puts a setting back to its default. */
|
|
789
|
+
update(patch: Record<string, unknown>, options?: UpdateOptions): Promise<{
|
|
790
|
+
record: SetupRecord;
|
|
791
|
+
dryRun?: boolean;
|
|
792
|
+
}>;
|
|
793
|
+
}
|
|
794
|
+
|
|
656
795
|
type UploadInput = Blob | ArrayBuffer | ArrayBufferView | Buffer;
|
|
657
796
|
interface UploadOptions {
|
|
658
797
|
mimeType?: string;
|
|
@@ -699,6 +838,12 @@ declare class Filecheck {
|
|
|
699
838
|
readonly rules: LibraryResource;
|
|
700
839
|
readonly profiles: LibraryResource;
|
|
701
840
|
readonly optimizePresets: LibraryResource;
|
|
841
|
+
readonly destinations: DestinationsResource;
|
|
842
|
+
readonly productMaps: ProductMapsResource;
|
|
843
|
+
readonly products: ProductsResource;
|
|
844
|
+
readonly settings: SettingsResource;
|
|
845
|
+
/** Webhook endpoints (`/webhooks`). `webhooks` is the signature-verification helper. */
|
|
846
|
+
readonly webhookEndpoints: WebhooksResource;
|
|
702
847
|
readonly webhooks: {
|
|
703
848
|
constructEvent: typeof constructEvent;
|
|
704
849
|
computeSignature: typeof computeSignature;
|
|
@@ -749,4 +894,4 @@ declare class ConnectionError extends FilecheckError {
|
|
|
749
894
|
declare class WebhookSignatureError extends FilecheckError {
|
|
750
895
|
}
|
|
751
896
|
|
|
752
|
-
export { APIError, type Artifact, AuthenticationError, ConnectionError, type ConstructEventOptions, type CreateJobParams, type CreateJobSource, type DeleteJobResult, type FetchLike, type FileType, Filecheck, type FilecheckClientOptions, FilecheckError, type FixParams, type FixSource, type HttpRequest, type HttpResponse, type HttpTransport, InvalidRequestError, type Job, type JobCompletedPayload, type JobContext, type JobCreatedPayload, type JobPage, type JobResult, type JobRuns, type JobStatus, type JobStepInput, type JobSummary, type LibraryItem, type ListJobsParams, NotFoundError, type OnFailPolicy, type OptimizeParams, type OptimizeResult, type OptimizeSource, type OrderResult, type Outcome, type PreflightParams, type PreflightResult, type PreflightSource, type PreviewsParams, type PreviewsSource, RateLimitError, type Run, type SourceRef, type Step, type StepType, TERMINAL_STATUSES, type Task, type UploadInput, type UploadOptions, type UploadResult, type ValidateParams, type ValidateProfileCode, type ValidateProfileResult, type ValidateResult, type ValidateSource, type VerifyOptions, type VerifyReason, type VerifyResult, type VerifyState, type WaitOptions, type WebhookEvent, type WebhookParam, WebhookSignatureError, computeSignature, constructEvent, Filecheck as default, isTerminal, maskKey, resolveVerify, webhooks };
|
|
897
|
+
export { APIError, type Artifact, AuthenticationError, ConnectionError, type ConstructEventOptions, type CreateJobParams, type CreateJobSource, type CreateOptions, type DeleteJobResult, type DeletedRecord, DestinationsResource, type FetchLike, type FileType, Filecheck, type FilecheckClientOptions, FilecheckError, type FixParams, type FixSource, type HttpRequest, type HttpResponse, type HttpTransport, InvalidRequestError, type Job, type JobCompletedPayload, type JobContext, type JobCreatedPayload, type JobPage, type JobResult, type JobRuns, type JobStatus, type JobStepInput, type JobSummary, type LibraryItem, LibraryResource, type ListJobsParams, NotFoundError, type OnFailPolicy, type OptimizeParams, type OptimizeResult, type OptimizeSource, type OrderResult, type Outcome, type PreflightParams, type PreflightResult, type PreflightSource, type PreviewsParams, type PreviewsSource, type ProductMap, ProductMapsResource, ProductsResource, type PublishResult, RateLimitError, RecordResource, type RevertResult, type Run, SettingsResource, type SetupRecord, type SourceRef, type Step, type StepType, type StoreProductPage, TERMINAL_STATUSES, type Task, type TestResult, type UpdateOptions, type UploadInput, type UploadOptions, type UploadResult, type ValidateParams, type ValidateProfileCode, type ValidateProfileResult, type ValidateResult, type ValidateSource, type VerifyOptions, type VerifyReason, type VerifyResult, type VerifyState, type WaitOptions, type WebhookEvent, type WebhookParam, WebhookSignatureError, WebhooksResource, type WriteResult, computeSignature, constructEvent, Filecheck as default, isTerminal, maskKey, resolveVerify, webhooks };
|