@wix/auto_sdk_data_indexes 1.0.49 → 1.0.51

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.
@@ -2,7 +2,9 @@ import { HttpClient, NonNullablePaths, EventDefinition, MaybeContext, BuildRESTF
2
2
  import { Index, ListIndexesOptions, ListIndexesResponse, IndexCreatedEnvelope, IndexDeletedEnvelope, IndexUpdatedEnvelope } from './index.typings.js';
3
3
  export { AccountInfo, AccountInfoMetadata, ActionEvent, BaseEventMetadata, CreateIndexRequest, CreateIndexResponse, DomainEvent, DomainEventBodyOneOf, DropIndexRequest, DropIndexResponse, EntityCreatedEvent, EntityDeletedEvent, EntityUpdatedEvent, Environment, EnvironmentWithLiterals, EventMetadata, Failure, Field, IdentificationData, IdentificationDataIdOneOf, IndexSource, IndexSourceWithLiterals, ListAvailableIndexesRequest, ListAvailableIndexesResponse, ListIndexesRequest, MessageEnvelope, Order, OrderWithLiterals, Paging, PagingMetadata, RestoreInfo, Status, StatusWithLiterals, WebhookIdentityType, WebhookIdentityTypeWithLiterals } from './index.typings.js';
4
4
 
5
- declare function createIndex$1(httpClient: HttpClient): CreateIndexSignature;
5
+ declare function createIndex$1(httpClient: HttpClient, __options?: {
6
+ validateRequestSchema?: boolean;
7
+ }): CreateIndexSignature;
6
8
  interface CreateIndexSignature {
7
9
  /**
8
10
  * Creates an index for a data collection.
@@ -19,7 +21,9 @@ interface CreateIndexSignature {
19
21
  */
20
22
  (dataCollectionId: string, index: NonNullablePaths<Index, `fields` | `fields.${number}.path` | `name`, 4>): Promise<NonNullablePaths<Index, `_id` | `name` | `fields` | `fields.${number}.path` | `fields.${number}.order` | `status` | `failure.code` | `failure.description` | `unique` | `caseInsensitive` | `source`, 4>>;
21
23
  }
22
- declare function dropIndex$1(httpClient: HttpClient): DropIndexSignature;
24
+ declare function dropIndex$1(httpClient: HttpClient, __options?: {
25
+ validateRequestSchema?: boolean;
26
+ }): DropIndexSignature;
23
27
  interface DropIndexSignature {
24
28
  /**
25
29
  * Removes an index from a data collection.
@@ -32,7 +36,9 @@ interface DropIndexSignature {
32
36
  */
33
37
  (dataCollectionId: string, indexName: string): Promise<void>;
34
38
  }
35
- declare function listIndexes$1(httpClient: HttpClient): ListIndexesSignature;
39
+ declare function listIndexes$1(httpClient: HttpClient, __options?: {
40
+ validateRequestSchema?: boolean;
41
+ }): ListIndexesSignature;
36
42
  interface ListIndexesSignature {
37
43
  /**
38
44
  * Lists all indexes defined for a data collection.
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
 
20
30
  // index.ts
@@ -491,6 +501,168 @@ function listAvailableIndexes(payload) {
491
501
  return __listAvailableIndexes;
492
502
  }
493
503
 
504
+ // src/data-v2-index-indexes.schemas.ts
505
+ var z = __toESM(require("zod"));
506
+ var CreateIndexRequest = z.object({
507
+ dataCollectionId: z.string().describe("ID of the data collection for which to generate the index.").max(256),
508
+ index: z.object({
509
+ _id: z.string().describe("ID of the index.").regex(
510
+ /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/,
511
+ "Must be a valid GUID"
512
+ ).optional(),
513
+ name: z.string().describe("Name of the index.").min(1).max(128),
514
+ fields: z.array(
515
+ z.object({
516
+ path: z.string().describe(
517
+ "Path of the field to index. For example: `title` or `options.price`."
518
+ ).min(1).max(128),
519
+ order: z.enum(["ASC", "DESC"]).optional()
520
+ })
521
+ ).min(1).max(3),
522
+ status: z.enum([
523
+ "UNKNOWN",
524
+ "BUILDING",
525
+ "ACTIVE",
526
+ "DROPPING",
527
+ "DROPPED",
528
+ "FAILED",
529
+ "INVALID"
530
+ ]).optional(),
531
+ failure: z.object({
532
+ code: z.string().describe(
533
+ "Error code.\n- `WDE0112`: Unknown error while building collection index.\n- `WDE0113`: Duplicate key error while building collection index.\n- `WDE0114`: Document too large while building collection index."
534
+ ).max(7).optional(),
535
+ description: z.string().describe("Description of the failure.").max(1024).optional(),
536
+ itemId: z.string().describe(
537
+ "ID of the data item that caused the failure.\nFor example, if `unique` is `true`, the ID of an item containing a duplicate value."
538
+ ).max(16e3).optional().nullable()
539
+ }).describe(
540
+ "Contains details about the reasons for failure when `status` is `FAILED`."
541
+ ).optional(),
542
+ unique: z.boolean().describe(
543
+ "Whether the index enforces uniqueness of values in the field for which it's defined.\nIf `true`, the index can have only 1 field.\n\nDefault: `false`"
544
+ ).optional(),
545
+ caseInsensitive: z.boolean().describe("Whether the index ignores case.\n\nDefault: `false`").optional(),
546
+ source: z.enum(["SYSTEM", "USER", "AUTO"]).optional()
547
+ }).describe("Details of the index to be created.")
548
+ });
549
+ var CreateIndexResponse = z.object({
550
+ _id: z.string().describe("ID of the index.").regex(
551
+ /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/,
552
+ "Must be a valid GUID"
553
+ ).optional(),
554
+ name: z.string().describe("Name of the index.").min(1).max(128).optional(),
555
+ fields: z.array(
556
+ z.object({
557
+ path: z.string().describe(
558
+ "Path of the field to index. For example: `title` or `options.price`."
559
+ ).min(1).max(128).optional(),
560
+ order: z.enum(["ASC", "DESC"]).describe(
561
+ "Sort order for the index. Base on how the data is regularly queried.\n\nDefault: `ASC`"
562
+ ).optional()
563
+ })
564
+ ).min(1).max(3).optional(),
565
+ status: z.enum([
566
+ "UNKNOWN",
567
+ "BUILDING",
568
+ "ACTIVE",
569
+ "DROPPING",
570
+ "DROPPED",
571
+ "FAILED",
572
+ "INVALID"
573
+ ]).describe("Current status of the index.").optional(),
574
+ failure: z.object({
575
+ code: z.string().describe(
576
+ "Error code.\n- `WDE0112`: Unknown error while building collection index.\n- `WDE0113`: Duplicate key error while building collection index.\n- `WDE0114`: Document too large while building collection index."
577
+ ).max(7).optional(),
578
+ description: z.string().describe("Description of the failure.").max(1024).optional(),
579
+ itemId: z.string().describe(
580
+ "ID of the data item that caused the failure.\nFor example, if `unique` is `true`, the ID of an item containing a duplicate value."
581
+ ).max(16e3).optional().nullable()
582
+ }).describe(
583
+ "Contains details about the reasons for failure when `status` is `FAILED`."
584
+ ).optional(),
585
+ unique: z.boolean().describe(
586
+ "Whether the index enforces uniqueness of values in the field for which it's defined.\nIf `true`, the index can have only 1 field.\n\nDefault: `false`"
587
+ ).optional(),
588
+ caseInsensitive: z.boolean().describe("Whether the index ignores case.\n\nDefault: `false`").optional(),
589
+ source: z.enum(["SYSTEM", "USER", "AUTO"]).describe(
590
+ "Source of the index. See index sources in [Index Types](https://dev.wix.com/docs/api-reference/business-solutions/cms/indexes/index-types#index-sources).\n\nDefault: `USER`"
591
+ ).optional()
592
+ });
593
+ var DropIndexRequest = z.object({
594
+ dataCollectionId: z.string().describe(
595
+ "ID of the data collection for which the index to be dropped is defined."
596
+ ).max(1024),
597
+ indexName: z.string().describe("Name of the index to drop.").min(1).max(128)
598
+ });
599
+ var DropIndexResponse = z.object({});
600
+ var ListIndexesRequest = z.object({
601
+ dataCollectionId: z.string().describe("ID of the data collection for which to list indexes.").max(1024),
602
+ options: z.object({
603
+ paging: z.object({
604
+ limit: z.number().int().describe("Number of items to load.").min(0).optional().nullable(),
605
+ offset: z.number().int().describe("Number of items to skip in the current sort order.").min(0).optional().nullable()
606
+ }).describe("Paging options to limit and skip the number of items.").optional()
607
+ }).describe("Options for retrieving a list of indexes.").optional()
608
+ });
609
+ var ListIndexesResponse = z.object({
610
+ indexes: z.array(
611
+ z.object({
612
+ _id: z.string().describe("ID of the index.").regex(
613
+ /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/,
614
+ "Must be a valid GUID"
615
+ ).optional(),
616
+ name: z.string().describe("Name of the index.").min(1).max(128).optional(),
617
+ fields: z.array(
618
+ z.object({
619
+ path: z.string().describe(
620
+ "Path of the field to index. For example: `title` or `options.price`."
621
+ ).min(1).max(128).optional(),
622
+ order: z.enum(["ASC", "DESC"]).describe(
623
+ "Sort order for the index. Base on how the data is regularly queried.\n\nDefault: `ASC`"
624
+ ).optional()
625
+ })
626
+ ).min(1).max(3).optional(),
627
+ status: z.enum([
628
+ "UNKNOWN",
629
+ "BUILDING",
630
+ "ACTIVE",
631
+ "DROPPING",
632
+ "DROPPED",
633
+ "FAILED",
634
+ "INVALID"
635
+ ]).describe("Current status of the index.").optional(),
636
+ failure: z.object({
637
+ code: z.string().describe(
638
+ "Error code.\n- `WDE0112`: Unknown error while building collection index.\n- `WDE0113`: Duplicate key error while building collection index.\n- `WDE0114`: Document too large while building collection index."
639
+ ).max(7).optional(),
640
+ description: z.string().describe("Description of the failure.").max(1024).optional(),
641
+ itemId: z.string().describe(
642
+ "ID of the data item that caused the failure.\nFor example, if `unique` is `true`, the ID of an item containing a duplicate value."
643
+ ).max(16e3).optional().nullable()
644
+ }).describe(
645
+ "Contains details about the reasons for failure when `status` is `FAILED`."
646
+ ).optional(),
647
+ unique: z.boolean().describe(
648
+ "Whether the index enforces uniqueness of values in the field for which it's defined.\nIf `true`, the index can have only 1 field.\n\nDefault: `false`"
649
+ ).optional(),
650
+ caseInsensitive: z.boolean().describe("Whether the index ignores case.\n\nDefault: `false`").optional(),
651
+ source: z.enum(["SYSTEM", "USER", "AUTO"]).describe(
652
+ "Source of the index. See index sources in [Index Types](https://dev.wix.com/docs/api-reference/business-solutions/cms/indexes/index-types#index-sources).\n\nDefault: `USER`"
653
+ ).optional()
654
+ })
655
+ ).optional(),
656
+ pagingMetadata: z.object({
657
+ count: z.number().int().describe("Number of items returned in the response.").optional().nullable(),
658
+ offset: z.number().int().describe("Offset that was requested.").optional().nullable(),
659
+ total: z.number().int().describe("Total number of items that match the query.").optional().nullable(),
660
+ tooManyToCount: z.boolean().describe(
661
+ "Flag that indicates the server failed to calculate the `total` field."
662
+ ).optional().nullable()
663
+ }).describe("Paging metadata.").optional()
664
+ });
665
+
494
666
  // src/data-v2-index-indexes.universal.ts
495
667
  var Order = /* @__PURE__ */ ((Order2) => {
496
668
  Order2["ASC"] = "ASC";
@@ -528,7 +700,10 @@ var WebhookIdentityType = /* @__PURE__ */ ((WebhookIdentityType2) => {
528
700
  return WebhookIdentityType2;
529
701
  })(WebhookIdentityType || {});
530
702
  async function createIndex2(dataCollectionId, index) {
531
- const { httpClient, sideEffects } = arguments[2];
703
+ const { httpClient, sideEffects, validateRequestSchema } = arguments[2];
704
+ if (validateRequestSchema) {
705
+ CreateIndexRequest.parse({ dataCollectionId, index });
706
+ }
532
707
  const payload = (0, import_rename_all_nested_keys.renameKeysFromSDKRequestToRESTRequest)({
533
708
  dataCollectionId,
534
709
  index
@@ -554,7 +729,10 @@ async function createIndex2(dataCollectionId, index) {
554
729
  }
555
730
  }
556
731
  async function dropIndex2(dataCollectionId, indexName) {
557
- const { httpClient, sideEffects } = arguments[2];
732
+ const { httpClient, sideEffects, validateRequestSchema } = arguments[2];
733
+ if (validateRequestSchema) {
734
+ DropIndexRequest.parse({ dataCollectionId, indexName });
735
+ }
558
736
  const payload = (0, import_rename_all_nested_keys.renameKeysFromSDKRequestToRESTRequest)({
559
737
  dataCollectionId,
560
738
  indexName
@@ -582,7 +760,10 @@ async function dropIndex2(dataCollectionId, indexName) {
582
760
  }
583
761
  }
584
762
  async function listIndexes2(dataCollectionId, options) {
585
- const { httpClient, sideEffects } = arguments[2];
763
+ const { httpClient, sideEffects, validateRequestSchema } = arguments[2];
764
+ if (validateRequestSchema) {
765
+ ListIndexesRequest.parse({ dataCollectionId, options });
766
+ }
586
767
  const payload = (0, import_rename_all_nested_keys.renameKeysFromSDKRequestToRESTRequest)({
587
768
  dataCollectionId,
588
769
  paging: options?.paging
@@ -637,35 +818,35 @@ async function listAvailableIndexes2(dataCollectionId) {
637
818
  }
638
819
 
639
820
  // src/data-v2-index-indexes.public.ts
640
- function createIndex3(httpClient) {
821
+ function createIndex3(httpClient, __options) {
641
822
  return (dataCollectionId, index) => createIndex2(
642
823
  dataCollectionId,
643
824
  index,
644
825
  // @ts-ignore
645
- { httpClient }
826
+ { httpClient, validateRequestSchema: __options?.validateRequestSchema }
646
827
  );
647
828
  }
648
- function dropIndex3(httpClient) {
829
+ function dropIndex3(httpClient, __options) {
649
830
  return (dataCollectionId, indexName) => dropIndex2(
650
831
  dataCollectionId,
651
832
  indexName,
652
833
  // @ts-ignore
653
- { httpClient }
834
+ { httpClient, validateRequestSchema: __options?.validateRequestSchema }
654
835
  );
655
836
  }
656
- function listIndexes3(httpClient) {
837
+ function listIndexes3(httpClient, __options) {
657
838
  return (dataCollectionId, options) => listIndexes2(
658
839
  dataCollectionId,
659
840
  options,
660
841
  // @ts-ignore
661
- { httpClient }
842
+ { httpClient, validateRequestSchema: __options?.validateRequestSchema }
662
843
  );
663
844
  }
664
- function listAvailableIndexes3(httpClient) {
845
+ function listAvailableIndexes3(httpClient, __options) {
665
846
  return (dataCollectionId) => listAvailableIndexes2(
666
847
  dataCollectionId,
667
848
  // @ts-ignore
668
- { httpClient }
849
+ { httpClient, validateRequestSchema: __options?.validateRequestSchema }
669
850
  );
670
851
  }
671
852
  var onIndexCreated = (0, import_sdk_types.EventDefinition)(