@arke-institute/sdk 3.0.0 → 3.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.
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * Source: Arke v1 API
8
8
  * Version: 1.0.0
9
- * Generated: 2026-02-06T01:10:39.896Z
9
+ * Generated: 2026-02-06T06:39:23.874Z
10
10
  */
11
11
  type paths = {
12
12
  "/ops-reference": {
@@ -1010,13 +1010,21 @@ type paths = {
1010
1010
  * Update collection properties
1011
1011
  * @description Updates collection properties. Requires collection:update permission.
1012
1012
  *
1013
+ * **Relationship Target Validation:**
1014
+ * By default, new relationship targets in `relationships_add` are validated to ensure they exist. Use `?validate_relationships=false` to skip this validation.
1015
+ *
1016
+ * Requests with more than 500 unique relationship targets are rejected when validation is enabled.
1017
+ *
1013
1018
  * ---
1014
1019
  * **Permission:** `collection:update`
1015
1020
  * **Auth:** required
1016
1021
  */
1017
1022
  put: {
1018
1023
  parameters: {
1019
- query?: never;
1024
+ query?: {
1025
+ /** @description Validate that relationship targets exist. Defaults to true for single entity operations, false for batch. When true, requests with >500 unique relationship targets are rejected. */
1026
+ validate_relationships?: "true" | "false";
1027
+ };
1020
1028
  header?: never;
1021
1029
  path: {
1022
1030
  /** @description Entity ID (ULID) */
@@ -3767,6 +3775,301 @@ type paths = {
3767
3775
  patch?: never;
3768
3776
  trace?: never;
3769
3777
  };
3778
+ "/entities/{id}/content/upload-url": {
3779
+ parameters: {
3780
+ query?: never;
3781
+ header?: never;
3782
+ path?: never;
3783
+ cookie?: never;
3784
+ };
3785
+ get?: never;
3786
+ put?: never;
3787
+ /**
3788
+ * Get presigned URL for direct upload
3789
+ * @description Returns a presigned URL for direct upload to R2 storage, bypassing the API worker.
3790
+ *
3791
+ * **When to use:**
3792
+ * - Files larger than 5MB (avoids streaming through API worker)
3793
+ * - Client has reliable network (single PUT request to R2)
3794
+ *
3795
+ * **Flow:**
3796
+ * 1. Call this endpoint to get presigned URL
3797
+ * 2. PUT file directly to the returned URL (include Content-Type header)
3798
+ * 3. Compute CID client-side
3799
+ * 4. Call POST /{id}/content/complete to finalize
3800
+ *
3801
+ * **Presigned URL:**
3802
+ * - Valid for 15 minutes
3803
+ * - Single use (upload replaces any existing content at key)
3804
+ * - Must include Content-Type header matching the request
3805
+ *
3806
+ * **Security:**
3807
+ * The presigned URL is the access control - it's signed and time-limited.
3808
+ * Without a valid URL from this endpoint, uploads to R2 will fail.
3809
+ *
3810
+ * **Note:** The CID is computed client-side and trusted. For guaranteed integrity,
3811
+ * use the direct upload endpoint (POST /{id}/content) which computes CID server-side.
3812
+ *
3813
+ * ---
3814
+ * **Permission:** `entity:update`
3815
+ * **Auth:** required
3816
+ */
3817
+ post: {
3818
+ parameters: {
3819
+ query?: never;
3820
+ header?: never;
3821
+ path: {
3822
+ /** @description Entity ID (ULID) */
3823
+ id: string;
3824
+ };
3825
+ cookie?: never;
3826
+ };
3827
+ requestBody?: {
3828
+ content: {
3829
+ "application/json": components["schemas"]["GetUploadUrlRequest"];
3830
+ };
3831
+ };
3832
+ responses: {
3833
+ /** @description Presigned URL generated */
3834
+ 200: {
3835
+ headers: {
3836
+ [name: string]: unknown;
3837
+ };
3838
+ content: {
3839
+ "application/json": components["schemas"]["GetUploadUrlResponse"];
3840
+ };
3841
+ };
3842
+ /** @description Bad Request - Invalid input */
3843
+ 400: {
3844
+ headers: {
3845
+ [name: string]: unknown;
3846
+ };
3847
+ content: {
3848
+ /**
3849
+ * @example {
3850
+ * "error": "Validation failed",
3851
+ * "details": {
3852
+ * "issues": [
3853
+ * {
3854
+ * "path": [
3855
+ * "properties",
3856
+ * "label"
3857
+ * ],
3858
+ * "message": "Required"
3859
+ * }
3860
+ * ]
3861
+ * }
3862
+ * }
3863
+ */
3864
+ "application/json": components["schemas"]["ValidationErrorResponse"];
3865
+ };
3866
+ };
3867
+ /** @description Unauthorized - Missing or invalid authentication */
3868
+ 401: {
3869
+ headers: {
3870
+ [name: string]: unknown;
3871
+ };
3872
+ content: {
3873
+ /**
3874
+ * @example {
3875
+ * "error": "Unauthorized: Missing or invalid authentication token"
3876
+ * }
3877
+ */
3878
+ "application/json": components["schemas"]["ErrorResponse"];
3879
+ };
3880
+ };
3881
+ /** @description Forbidden - Insufficient permissions */
3882
+ 403: {
3883
+ headers: {
3884
+ [name: string]: unknown;
3885
+ };
3886
+ content: {
3887
+ /**
3888
+ * @example {
3889
+ * "error": "Forbidden: You do not have permission to perform this action"
3890
+ * }
3891
+ */
3892
+ "application/json": components["schemas"]["ErrorResponse"];
3893
+ };
3894
+ };
3895
+ /** @description Not Found - Resource does not exist */
3896
+ 404: {
3897
+ headers: {
3898
+ [name: string]: unknown;
3899
+ };
3900
+ content: {
3901
+ /**
3902
+ * @example {
3903
+ * "error": "Entity not found"
3904
+ * }
3905
+ */
3906
+ "application/json": components["schemas"]["ErrorResponse"];
3907
+ };
3908
+ };
3909
+ };
3910
+ };
3911
+ delete?: never;
3912
+ options?: never;
3913
+ head?: never;
3914
+ patch?: never;
3915
+ trace?: never;
3916
+ };
3917
+ "/entities/{id}/content/complete": {
3918
+ parameters: {
3919
+ query?: never;
3920
+ header?: never;
3921
+ path?: never;
3922
+ cookie?: never;
3923
+ };
3924
+ get?: never;
3925
+ put?: never;
3926
+ /**
3927
+ * Complete presigned URL upload
3928
+ * @description Finalizes a presigned URL upload by updating entity metadata.
3929
+ *
3930
+ * **Prerequisites:**
3931
+ * 1. Called POST /{id}/content/upload-url to get presigned URL
3932
+ * 2. Uploaded file directly to R2 via presigned URL
3933
+ * 3. Computed CID client-side
3934
+ *
3935
+ * **Request:**
3936
+ * - `key`: Same key used in upload-url request
3937
+ * - `cid`: Content-addressed identifier computed by client
3938
+ * - `size`: Actual file size in bytes
3939
+ * - `content_type`: MIME type of uploaded content
3940
+ * - `expect_tip`: Current entity tip for CAS protection
3941
+ *
3942
+ * **Behavior:**
3943
+ * - Verifies file exists in R2 at expected location
3944
+ * - Updates entity with content metadata
3945
+ * - Creates new entity version
3946
+ *
3947
+ * **CID Trust:**
3948
+ * The client-provided CID is trusted without server verification.
3949
+ * For guaranteed integrity, use direct upload (POST /{id}/content).
3950
+ *
3951
+ * ---
3952
+ * **Permission:** `entity:update`
3953
+ * **Auth:** required
3954
+ */
3955
+ post: {
3956
+ parameters: {
3957
+ query?: never;
3958
+ header?: never;
3959
+ path: {
3960
+ /** @description Entity ID (ULID) */
3961
+ id: string;
3962
+ };
3963
+ cookie?: never;
3964
+ };
3965
+ requestBody?: {
3966
+ content: {
3967
+ "application/json": components["schemas"]["CompleteUploadRequest"];
3968
+ };
3969
+ };
3970
+ responses: {
3971
+ /** @description Upload completed */
3972
+ 200: {
3973
+ headers: {
3974
+ [name: string]: unknown;
3975
+ };
3976
+ content: {
3977
+ "application/json": components["schemas"]["CompleteUploadResponse"];
3978
+ };
3979
+ };
3980
+ /** @description Bad Request - Invalid input */
3981
+ 400: {
3982
+ headers: {
3983
+ [name: string]: unknown;
3984
+ };
3985
+ content: {
3986
+ /**
3987
+ * @example {
3988
+ * "error": "Validation failed",
3989
+ * "details": {
3990
+ * "issues": [
3991
+ * {
3992
+ * "path": [
3993
+ * "properties",
3994
+ * "label"
3995
+ * ],
3996
+ * "message": "Required"
3997
+ * }
3998
+ * ]
3999
+ * }
4000
+ * }
4001
+ */
4002
+ "application/json": components["schemas"]["ValidationErrorResponse"];
4003
+ };
4004
+ };
4005
+ /** @description Unauthorized - Missing or invalid authentication */
4006
+ 401: {
4007
+ headers: {
4008
+ [name: string]: unknown;
4009
+ };
4010
+ content: {
4011
+ /**
4012
+ * @example {
4013
+ * "error": "Unauthorized: Missing or invalid authentication token"
4014
+ * }
4015
+ */
4016
+ "application/json": components["schemas"]["ErrorResponse"];
4017
+ };
4018
+ };
4019
+ /** @description Forbidden - Insufficient permissions */
4020
+ 403: {
4021
+ headers: {
4022
+ [name: string]: unknown;
4023
+ };
4024
+ content: {
4025
+ /**
4026
+ * @example {
4027
+ * "error": "Forbidden: You do not have permission to perform this action"
4028
+ * }
4029
+ */
4030
+ "application/json": components["schemas"]["ErrorResponse"];
4031
+ };
4032
+ };
4033
+ /** @description Not Found - Resource does not exist */
4034
+ 404: {
4035
+ headers: {
4036
+ [name: string]: unknown;
4037
+ };
4038
+ content: {
4039
+ /**
4040
+ * @example {
4041
+ * "error": "Entity not found"
4042
+ * }
4043
+ */
4044
+ "application/json": components["schemas"]["ErrorResponse"];
4045
+ };
4046
+ };
4047
+ /** @description Conflict - CAS validation failed (entity was modified) */
4048
+ 409: {
4049
+ headers: {
4050
+ [name: string]: unknown;
4051
+ };
4052
+ content: {
4053
+ /**
4054
+ * @example {
4055
+ * "error": "Conflict: entity was modified",
4056
+ * "details": {
4057
+ * "expected": "bafyreibug443cnd4endcwinwttw3c3dzmcl2ikht64xzn5qg56bix3usfy",
4058
+ * "actual": "bafyreinewabc123456789defghijklmnopqrstuvwxyz"
4059
+ * }
4060
+ * }
4061
+ */
4062
+ "application/json": components["schemas"]["CASErrorResponse"];
4063
+ };
4064
+ };
4065
+ };
4066
+ };
4067
+ delete?: never;
4068
+ options?: never;
4069
+ head?: never;
4070
+ patch?: never;
4071
+ trace?: never;
4072
+ };
3770
4073
  "/versions/{id}": {
3771
4074
  parameters: {
3772
4075
  query?: never;
@@ -10134,6 +10437,97 @@ type components = {
10134
10437
  */
10135
10438
  prev_cid: string;
10136
10439
  };
10440
+ GetUploadUrlResponse: {
10441
+ /**
10442
+ * Format: uri
10443
+ * @description Presigned URL for direct PUT upload to R2
10444
+ * @example https://xxx.r2.cloudflarestorage.com/...
10445
+ */
10446
+ upload_url: string;
10447
+ /**
10448
+ * @description R2 storage key (for reference)
10449
+ * @example 01KABC123.../v1
10450
+ */
10451
+ r2_key: string;
10452
+ /**
10453
+ * Format: date-time
10454
+ * @description ISO 8601 timestamp when the URL expires
10455
+ * @example 2025-01-15T10:15:00Z
10456
+ */
10457
+ expires_at: string;
10458
+ };
10459
+ GetUploadUrlRequest: {
10460
+ /**
10461
+ * @description MIME type of the content to upload
10462
+ * @example application/pdf
10463
+ */
10464
+ content_type: string;
10465
+ /**
10466
+ * @description Expected file size in bytes (max 500 MB)
10467
+ * @example 10485760
10468
+ */
10469
+ size: number;
10470
+ /**
10471
+ * @description Original filename for Content-Disposition on download
10472
+ * @example document.pdf
10473
+ */
10474
+ filename?: string;
10475
+ /**
10476
+ * @description Version key for this content (e.g., "v1", "original")
10477
+ * @example v1
10478
+ */
10479
+ key: string;
10480
+ };
10481
+ CompleteUploadResponse: {
10482
+ /**
10483
+ * @description Entity ID
10484
+ * @example 01KABC123...
10485
+ */
10486
+ id: string;
10487
+ /**
10488
+ * @description New entity manifest CID after update
10489
+ * @example bafyrei...
10490
+ */
10491
+ cid: string;
10492
+ content: components["schemas"]["ContentMetadata"] & unknown;
10493
+ /**
10494
+ * @description Previous entity manifest CID
10495
+ * @example bafyrei...
10496
+ */
10497
+ prev_cid: string;
10498
+ };
10499
+ CompleteUploadRequest: {
10500
+ /**
10501
+ * @description Version key used in upload-url request
10502
+ * @example v1
10503
+ */
10504
+ key: string;
10505
+ /**
10506
+ * @description Content-addressed identifier computed by client
10507
+ * @example bafyreih5iy6dqwbcslkqpx6bxwj7qy3z5x...
10508
+ */
10509
+ cid: string;
10510
+ /**
10511
+ * @description Actual file size in bytes
10512
+ * @example 10485760
10513
+ */
10514
+ size: number;
10515
+ /**
10516
+ * @description MIME type of the uploaded content
10517
+ * @example application/pdf
10518
+ */
10519
+ content_type: string;
10520
+ /**
10521
+ * @description Original filename for Content-Disposition
10522
+ * @example document.pdf
10523
+ */
10524
+ filename?: string;
10525
+ /**
10526
+ * @description Expected current tip CID for CAS protection
10527
+ * @example bafyrei...
10528
+ */
10529
+ expect_tip: string;
10530
+ };
10137
10531
  VersionInfo: {
10138
10532
  /**
10139
10533
  * @description Entity version number