cmx-sdk 0.1.18 → 0.1.20

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/cli.js CHANGED
@@ -1657,6 +1657,18 @@ async function createDataEntry(options) {
1657
1657
  config();
1658
1658
  var program = new Command();
1659
1659
  program.name("cmx-sdk").description("CMX SDK - CLI tool for managing CMX schemas and content").version("0.1.13");
1660
+ program.action(async () => {
1661
+ const { interactiveMenu } = await import("./interactive-menu-CHY4LUNZ.js");
1662
+ await interactiveMenu();
1663
+ });
1664
+ program.command("init [project-name]").description("\u65B0\u898F CMX \u30B5\u30A4\u30C8\u3092\u4F5C\u6210").option("--no-studio", "CMX Studio \u3092\u30B9\u30AD\u30C3\u30D7").option("--pm <manager>", "\u30D1\u30C3\u30B1\u30FC\u30B8\u30DE\u30CD\u30FC\u30B8\u30E3\u30FC (npm, pnpm, yarn)").action(async (projectName, options) => {
1665
+ const { init } = await import("./init-UITQ2MSM.js");
1666
+ await init(projectName, options);
1667
+ });
1668
+ program.command("studio").description("\u30B5\u30A4\u30C8 + CMX Studio \u3092\u8D77\u52D5").option("--only", "Studio \u306E\u307F\u8D77\u52D5\uFF08\u30B5\u30A4\u30C8\u306F\u8D77\u52D5\u3057\u306A\u3044\uFF09").action(async (options) => {
1669
+ const { studio } = await import("./studio-76GY2A5B.js");
1670
+ await studio(options);
1671
+ });
1660
1672
  program.command("list-collections").description("List all collections").action(listCollections);
1661
1673
  program.command("list-data-types").description("List all data types").action(listDataTypes);
1662
1674
  program.command("list-forms").description("List all form definitions").action(listForms);
package/dist/index.d.ts CHANGED
@@ -339,6 +339,10 @@ interface PublicContentListItem {
339
339
  interface CollectionContentsResponse {
340
340
  collection: PublicCollectionInfo;
341
341
  contents: PublicContentListItem[];
342
+ /** フィルタ条件に合致する総件数 */
343
+ totalCount: number;
344
+ /** 次のページが存在するか */
345
+ hasNext: boolean;
342
346
  }
343
347
 
344
348
  /**
@@ -371,6 +375,8 @@ interface ReferenceField {
371
375
  /** @minLength 1 */
372
376
  label: string;
373
377
  referenceType: ReferenceFieldReferenceType;
378
+ /** 必須フィールドかどうか */
379
+ required: boolean;
374
380
  sortOrder: number;
375
381
  /** データタイプ名 */
376
382
  dataTypeName?: string;
@@ -490,6 +496,19 @@ interface FieldOptions {
490
496
  targetType?: string;
491
497
  }
492
498
 
499
+ /**
500
+ * Generated by orval v7.17.2 🍺
501
+ * Do not edit manually.
502
+ * CMX SDK API
503
+ * CMX SDK API(コンテンツ配信+管理)
504
+ * OpenAPI spec version: 1.0.0
505
+ */
506
+ /**
507
+ * 未入力時のデフォルト値
508
+ * @nullable
509
+ */
510
+ type FieldDefinitionDefaultValue = unknown | null;
511
+
493
512
  /**
494
513
  * Generated by orval v7.17.2 🍺
495
514
  * Do not edit manually.
@@ -512,9 +531,18 @@ interface FieldDefinition {
512
531
  label: string;
513
532
  /** 必須フラグ */
514
533
  required: boolean;
534
+ /** 一意制約フラグ */
535
+ unique?: boolean;
536
+ /** 大文字小文字を区別しない一意制約 */
537
+ uniqueCaseInsensitive?: boolean;
515
538
  /** ヘルプテキスト */
516
539
  description?: string;
517
540
  options?: FieldOptions;
541
+ /**
542
+ * 未入力時のデフォルト値
543
+ * @nullable
544
+ */
545
+ defaultValue?: FieldDefinitionDefaultValue;
518
546
  }
519
547
 
520
548
  /**
@@ -557,6 +585,17 @@ interface CreateFormDefinitionRequest {
557
585
  enabled?: boolean;
558
586
  }
559
587
 
588
+ /**
589
+ * Generated by orval v7.17.2 🍺
590
+ * Do not edit manually.
591
+ * CMX SDK API
592
+ * CMX SDK API(コンテンツ配信+管理)
593
+ * OpenAPI spec version: 1.0.0
594
+ */
595
+ interface DataEntryDetailResponse {
596
+ [key: string]: unknown | null;
597
+ }
598
+
560
599
  /**
561
600
  * Generated by orval v7.17.2 🍺
562
601
  * Do not edit manually.
@@ -579,7 +618,10 @@ interface DataEntryItem {
579
618
  interface DataListResponse {
580
619
  type: string;
581
620
  items: DataEntryItem[];
621
+ /** 返却されたアイテム数 */
582
622
  count: number;
623
+ /** フィルタ条件に合致する総件数 */
624
+ totalCount: number;
583
625
  }
584
626
 
585
627
  /**
@@ -685,6 +727,55 @@ interface FormDefinitionResponse {
685
727
  updatedAt: Date;
686
728
  }
687
729
 
730
+ /**
731
+ * Generated by orval v7.17.2 🍺
732
+ * Do not edit manually.
733
+ * CMX SDK API
734
+ * CMX SDK API(コンテンツ配信+管理)
735
+ * OpenAPI spec version: 1.0.0
736
+ */
737
+ type GetCollectionsSlugContentsSortBy = typeof GetCollectionsSlugContentsSortBy[keyof typeof GetCollectionsSlugContentsSortBy];
738
+ declare const GetCollectionsSlugContentsSortBy: {
739
+ readonly publishedAt: "publishedAt";
740
+ readonly sortOrder: "sortOrder";
741
+ };
742
+
743
+ /**
744
+ * Generated by orval v7.17.2 🍺
745
+ * Do not edit manually.
746
+ * CMX SDK API
747
+ * CMX SDK API(コンテンツ配信+管理)
748
+ * OpenAPI spec version: 1.0.0
749
+ */
750
+ type GetCollectionsSlugContentsSortOrder = typeof GetCollectionsSlugContentsSortOrder[keyof typeof GetCollectionsSlugContentsSortOrder];
751
+ declare const GetCollectionsSlugContentsSortOrder: {
752
+ readonly asc: "asc";
753
+ readonly desc: "desc";
754
+ };
755
+
756
+ /**
757
+ * Generated by orval v7.17.2 🍺
758
+ * Do not edit manually.
759
+ * CMX SDK API
760
+ * CMX SDK API(コンテンツ配信+管理)
761
+ * OpenAPI spec version: 1.0.0
762
+ */
763
+
764
+ type GetCollectionsSlugContentsParams = {
765
+ sortBy?: GetCollectionsSlugContentsSortBy;
766
+ sortOrder?: GetCollectionsSlugContentsSortOrder;
767
+ /**
768
+ * @minimum 1
769
+ * @maximum 100
770
+ */
771
+ limit?: number;
772
+ /**
773
+ * @minimum 0
774
+ * @nullable
775
+ */
776
+ offset?: number | null;
777
+ };
778
+
688
779
  /**
689
780
  * Generated by orval v7.17.2 🍺
690
781
  * Do not edit manually.
@@ -747,20 +838,6 @@ declare const SdkPresetReferenceType: {
747
838
  readonly multiple: "multiple";
748
839
  };
749
840
 
750
- /**
751
- * Generated by orval v7.17.2 🍺
752
- * Do not edit manually.
753
- * CMX SDK API
754
- * CMX SDK API(コンテンツ配信+管理)
755
- * OpenAPI spec version: 1.0.0
756
- */
757
- interface SdkPresetField {
758
- key: string;
759
- label: string;
760
- type: string;
761
- required?: boolean;
762
- }
763
-
764
841
  /**
765
842
  * Generated by orval v7.17.2 🍺
766
843
  * Do not edit manually.
@@ -776,7 +853,7 @@ interface SdkPreset {
776
853
  default: boolean;
777
854
  hierarchical: boolean;
778
855
  referenceType: SdkPresetReferenceType;
779
- fields: SdkPresetField[];
856
+ fields: FieldDefinition[];
780
857
  }
781
858
 
782
859
  /**
@@ -1764,8 +1841,8 @@ type getCollectionsSlugContentsResponseError = (getCollectionsSlugContentsRespon
1764
1841
  headers: Headers;
1765
1842
  };
1766
1843
  type getCollectionsSlugContentsResponse = (getCollectionsSlugContentsResponseSuccess | getCollectionsSlugContentsResponseError);
1767
- declare const getGetCollectionsSlugContentsUrl: (slug: string) => string;
1768
- declare const getCollectionsSlugContents: (slug: string, options?: RequestInit) => Promise<getCollectionsSlugContentsResponse>;
1844
+ declare const getGetCollectionsSlugContentsUrl: (slug: string, params?: GetCollectionsSlugContentsParams) => string;
1845
+ declare const getCollectionsSlugContents: (slug: string, params?: GetCollectionsSlugContentsParams, options?: RequestInit) => Promise<getCollectionsSlugContentsResponse>;
1769
1846
  /**
1770
1847
  * @summary コレクションの公開済みコンテンツ詳細を取得(参照解決済み)
1771
1848
  */
@@ -1917,6 +1994,14 @@ declare function getDataEntryOrThrow(typeSlug: string, id: string, options?: Fet
1917
1994
  * Returns null if the token is invalid or expired.
1918
1995
  */
1919
1996
  declare function getPreviewByToken(token: string): Promise<PreviewResponse | null>;
1997
+ /**
1998
+ * Get the workspace schema (collections, data types, forms)
1999
+ */
2000
+ declare function getSchema(options?: FetchOptions): Promise<SchemaResponse>;
2001
+ /**
2002
+ * Get all collections in the workspace
2003
+ */
2004
+ declare function getCollections(options?: FetchOptions): Promise<SchemaResponse["collections"]>;
1920
2005
  /**
1921
2006
  * Submit data to a public form
1922
2007
  * Only works for data types with publicSubmission enabled.
@@ -2303,4 +2388,4 @@ declare function renderMdx(mdx: string, references?: References, options?: Rende
2303
2388
  */
2304
2389
  declare function renderMdxPreview(mdx: string, additionalComponents?: Record<string, React.ComponentType<any>>): Promise<React.ReactElement>;
2305
2390
 
2306
- export { type ApiResponse, type AssetReference, type AssetReferenceVariants, BlogCard, Button, CACHE_TAGS, Callout, CmxApiError, type CollectionConfig, type CollectionConfigDefaults, type CollectionContentDetailResponse, type CollectionContentsOptions, type CollectionContentsResponse, type CollectionListResponse, type CollectionResponse, CollectionType, type ComponentDefinition, type ComponentName, type ContentReference, type CreateCollectionRequest, type CreateDataTypeRequest, type CreateFormDefinitionRequest, type DataEntriesOptions, type DataEntryItem, type DataListResponse, type DataTypeConfig, type DataTypeResponse, Embed, type ErrorResponse, type ErrorResponseDetails, type FetchOptions, type FieldDefinition, type FieldOptions, type FieldOptionsChoicesItem, FieldType, type FormDefinitionResponse, type FormDefinitionResponseConfigJson, type GetDataTypeSlugParams, GetDataTypeSlugSortBy, GetDataTypeSlugSortOrder, type GetManageCollectionPresets200, type GetManageCollectionPresetsParams, GetManageCollectionPresetsType, type GetManageDataTypeSlugParams, GetManageDataTypeSlugSortBy, GetManageDataTypeSlugSortOrder, GetManageDataTypeSlugStatus, type GetPreviewToken200, type GetPreviewToken200Collection, type GetPreviewToken200Content, type GetPreviewToken200References, type GetPreviewToken200ReferencesAssets, type GetPreviewToken200ReferencesAssetsVariants, type GetPreviewToken200ReferencesContents, Image, type PreviewResponse, type PublicCollectionInfo, type PublicContentDetail, type PublicContentListItem, type PublicContentParent, type PublicFetcherOptions, type PublicSubmissionRequest, type PublicSubmissionRequestData, type PublicSubmissionResponse, type ReferenceField, ReferenceFieldReferenceType, type References, type ReferencesAssets, type ReferencesContents, type RenderOptions, type RenderResult, type ResolvedReferences, type RevalidationConfig, type SchemaCollection, type SchemaDataType, type SchemaFieldDefinition, type SchemaFieldOption, type SchemaFieldOptionChoicesItem, type SchemaFormDefinition, type SchemaResponse, type SdkAddCollectionDataTypeRequest, SdkAddCollectionDataTypeRequestReferenceType, type SdkCollectionDataTypeResponse, type SdkCollectionDataTypeResponseAllOf, type SdkComponentDefinition, type SdkComponentDefinitionPropsSchema, type SdkComponentProp, type SdkComponentPropDefault, type SdkComponentSuccessResponse, type SdkComponentSyncRequest, type SdkCreateEntryRequest, type SdkCreateEntryRequestDataJson, SdkCreateEntryRequestStatus, type SdkCustomComponentResponse, type SdkCustomComponentResponsePropsSchema, type SdkCustomComponentsListResponse, type SdkDataEntriesListResponse, type SdkDataEntryDetailResponse, type SdkDataEntryResponse, type SdkDataEntryResponseCreatedAt, type SdkDataEntryResponseDataJson, SdkDataEntryResponseStatus, type SdkDataEntryResponseUpdatedAt, type SdkDataTypeInfo, type SdkDeleteCollectionDataTypeResponse, type SdkDeleteCollectionResponse, type SdkDeleteDataEntryResponse, type SdkDeleteDataTypeResponse, type SdkDeleteFormDefinitionResponse, type SdkLinkExistingDataTypeRequest, SdkLinkExistingDataTypeRequestReferenceType, type SdkPreset, type SdkPresetField, SdkPresetReferenceType, type SdkUpdateEntryRequest, type SdkUpdateEntryRequestDataJson, SdkUpdateEntryRequestStatus, type UpdateCollectionRequest, type UpdateDataTypeRequest, type UpdateFormDefinitionRequest, type UpdateFormDefinitionRequestConfigJson, type ValidationError, type ValidationResult, basicComponents, componentCatalog, componentSchemas, customComponents, getCatalogForAI, getCollectionContentDetail, getCollectionContentDetailOrThrow, getCollectionContents, getCollectionContentsOrThrow, getCollectionsSlugContents, getCollectionsSlugContentsContentSlug, getComponentsByCategory, getComponentsWithReferences, getDataEntries, getDataEntriesOrThrow, getDataEntry, getDataEntryOrThrow, getDataTypeSlug, getGetCollectionsSlugContentsContentSlugUrl, getGetCollectionsSlugContentsUrl, getGetDataTypeSlugUrl, getGetPreviewTokenUrl, getPreviewByToken, getPreviewToken, getSdkApiBaseUrl, getSdkApiToken, isValidComponent, markdownComponents, mdxComponents, quickValidateMdx, renderMdx, renderMdxPreview, sdkCustomInstance, sdkFetchWithTags, sdkFetcher, sdkPostFetcher, submitFormData, validateComponentProps, validateMdx };
2391
+ export { type ApiResponse, type AssetReference, type AssetReferenceVariants, BlogCard, Button, CACHE_TAGS, Callout, CmxApiError, type CollectionConfig, type CollectionConfigDefaults, type CollectionContentDetailResponse, type CollectionContentsOptions, type CollectionContentsResponse, type CollectionListResponse, type CollectionResponse, CollectionType, type ComponentDefinition, type ComponentName, type ContentReference, type CreateCollectionRequest, type CreateDataTypeRequest, type CreateFormDefinitionRequest, type DataEntriesOptions, type DataEntryDetailResponse, type DataEntryItem, type DataListResponse, type DataTypeConfig, type DataTypeResponse, Embed, type ErrorResponse, type ErrorResponseDetails, type FetchOptions, type FieldDefinition, type FieldDefinitionDefaultValue, type FieldOptions, type FieldOptionsChoicesItem, FieldType, type FormDefinitionResponse, type FormDefinitionResponseConfigJson, type GetCollectionsSlugContentsParams, GetCollectionsSlugContentsSortBy, GetCollectionsSlugContentsSortOrder, type GetDataTypeSlugParams, GetDataTypeSlugSortBy, GetDataTypeSlugSortOrder, type GetManageCollectionPresets200, type GetManageCollectionPresetsParams, GetManageCollectionPresetsType, type GetManageDataTypeSlugParams, GetManageDataTypeSlugSortBy, GetManageDataTypeSlugSortOrder, GetManageDataTypeSlugStatus, type GetPreviewToken200, type GetPreviewToken200Collection, type GetPreviewToken200Content, type GetPreviewToken200References, type GetPreviewToken200ReferencesAssets, type GetPreviewToken200ReferencesAssetsVariants, type GetPreviewToken200ReferencesContents, Image, type PreviewResponse, type PublicCollectionInfo, type PublicContentDetail, type PublicContentListItem, type PublicContentParent, type PublicFetcherOptions, type PublicSubmissionRequest, type PublicSubmissionRequestData, type PublicSubmissionResponse, type ReferenceField, ReferenceFieldReferenceType, type References, type ReferencesAssets, type ReferencesContents, type RenderOptions, type RenderResult, type ResolvedReferences, type RevalidationConfig, type SchemaCollection, type SchemaDataType, type SchemaFieldDefinition, type SchemaFieldOption, type SchemaFieldOptionChoicesItem, type SchemaFormDefinition, type SchemaResponse, type SdkAddCollectionDataTypeRequest, SdkAddCollectionDataTypeRequestReferenceType, type SdkCollectionDataTypeResponse, type SdkCollectionDataTypeResponseAllOf, type SdkComponentDefinition, type SdkComponentDefinitionPropsSchema, type SdkComponentProp, type SdkComponentPropDefault, type SdkComponentSuccessResponse, type SdkComponentSyncRequest, type SdkCreateEntryRequest, type SdkCreateEntryRequestDataJson, SdkCreateEntryRequestStatus, type SdkCustomComponentResponse, type SdkCustomComponentResponsePropsSchema, type SdkCustomComponentsListResponse, type SdkDataEntriesListResponse, type SdkDataEntryDetailResponse, type SdkDataEntryResponse, type SdkDataEntryResponseCreatedAt, type SdkDataEntryResponseDataJson, SdkDataEntryResponseStatus, type SdkDataEntryResponseUpdatedAt, type SdkDataTypeInfo, type SdkDeleteCollectionDataTypeResponse, type SdkDeleteCollectionResponse, type SdkDeleteDataEntryResponse, type SdkDeleteDataTypeResponse, type SdkDeleteFormDefinitionResponse, type SdkLinkExistingDataTypeRequest, SdkLinkExistingDataTypeRequestReferenceType, type SdkPreset, SdkPresetReferenceType, type SdkUpdateEntryRequest, type SdkUpdateEntryRequestDataJson, SdkUpdateEntryRequestStatus, type UpdateCollectionRequest, type UpdateDataTypeRequest, type UpdateFormDefinitionRequest, type UpdateFormDefinitionRequestConfigJson, type ValidationError, type ValidationResult, basicComponents, componentCatalog, componentSchemas, customComponents, getCatalogForAI, getCollectionContentDetail, getCollectionContentDetailOrThrow, getCollectionContents, getCollectionContentsOrThrow, getCollections, getCollectionsSlugContents, getCollectionsSlugContentsContentSlug, getComponentsByCategory, getComponentsWithReferences, getDataEntries, getDataEntriesOrThrow, getDataEntry, getDataEntryOrThrow, getDataTypeSlug, getGetCollectionsSlugContentsContentSlugUrl, getGetCollectionsSlugContentsUrl, getGetDataTypeSlugUrl, getGetPreviewTokenUrl, getPreviewByToken, getPreviewToken, getSchema, getSdkApiBaseUrl, getSdkApiToken, isValidComponent, markdownComponents, mdxComponents, quickValidateMdx, renderMdx, renderMdxPreview, sdkCustomInstance, sdkFetchWithTags, sdkFetcher, sdkPostFetcher, submitFormData, validateComponentProps, validateMdx };
package/dist/index.js CHANGED
@@ -143,12 +143,19 @@ function dateReviver(_key, value) {
143
143
  }
144
144
 
145
145
  // src/generated/sdk/endpoints/sdk.ts
146
- var getGetCollectionsSlugContentsUrl = (slug) => {
147
- return `/api/v1/sdk/collections/${slug}/contents`;
146
+ var getGetCollectionsSlugContentsUrl = (slug, params) => {
147
+ const normalizedParams = new URLSearchParams();
148
+ Object.entries(params || {}).forEach(([key, value]) => {
149
+ if (value !== void 0) {
150
+ normalizedParams.append(key, value === null ? "null" : value.toString());
151
+ }
152
+ });
153
+ const stringifiedParams = normalizedParams.toString();
154
+ return stringifiedParams.length > 0 ? `/api/v1/sdk/collections/${slug}/contents?${stringifiedParams}` : `/api/v1/sdk/collections/${slug}/contents`;
148
155
  };
149
- var getCollectionsSlugContents = async (slug, options) => {
156
+ var getCollectionsSlugContents = async (slug, params, options) => {
150
157
  const res = await fetch(
151
- getGetCollectionsSlugContentsUrl(slug),
158
+ getGetCollectionsSlugContentsUrl(slug, params),
152
159
  {
153
160
  ...options,
154
161
  method: "GET"
@@ -295,6 +302,17 @@ async function getPreviewByToken(token) {
295
302
  return null;
296
303
  }
297
304
  }
305
+ async function getSchema(options) {
306
+ return sdkFetchWithTags(
307
+ "/schema",
308
+ [CACHE_TAGS.collections, CACHE_TAGS.data],
309
+ options?.revalidate
310
+ );
311
+ }
312
+ async function getCollections(options) {
313
+ const schema = await getSchema(options);
314
+ return schema.collections;
315
+ }
298
316
  async function submitFormData(typeSlug, data) {
299
317
  return sdkPostFetcher(
300
318
  `/submissions/${encodeURIComponent(typeSlug)}`,
@@ -1072,6 +1090,7 @@ export {
1072
1090
  getCollectionContentDetailOrThrow,
1073
1091
  getCollectionContents,
1074
1092
  getCollectionContentsOrThrow,
1093
+ getCollections,
1075
1094
  getCollectionsSlugContents,
1076
1095
  getCollectionsSlugContentsContentSlug,
1077
1096
  getComponentsByCategory,
@@ -1087,6 +1106,7 @@ export {
1087
1106
  getGetPreviewTokenUrl,
1088
1107
  getPreviewByToken,
1089
1108
  getPreviewToken,
1109
+ getSchema,
1090
1110
  getSdkApiBaseUrl,
1091
1111
  getSdkApiToken,
1092
1112
  isValidComponent,