@sanity/cli 6.0.0-alpha.3 → 6.0.0-alpha.5
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/actions/auth/login/{index.js → login.js} +1 -1
- package/dist/actions/auth/login/{index.js.map → login.js.map} +1 -1
- package/dist/actions/dev/startStudioDevServer.js +3 -8
- package/dist/actions/dev/startStudioDevServer.js.map +1 -1
- package/dist/actions/dev/types.d.ts +1 -3
- package/dist/actions/dev/types.js.map +1 -1
- package/dist/actions/documents/validate.d.ts +0 -2
- package/dist/actions/documents/validate.js +21 -1
- package/dist/actions/documents/validate.js.map +1 -1
- package/dist/actions/exec/execScript.js +1 -1
- package/dist/actions/exec/execScript.js.map +1 -1
- package/dist/actions/graphql/__tests__/getGraphQLAPIs.test.js +1 -1
- package/dist/actions/graphql/__tests__/getGraphQLAPIs.test.js.map +1 -1
- package/dist/actions/graphql/getGraphQLAPIs.js +1 -1
- package/dist/actions/graphql/getGraphQLAPIs.js.map +1 -1
- package/dist/actions/manifest/extractManifest.js +1 -4
- package/dist/actions/manifest/extractManifest.js.map +1 -1
- package/dist/actions/organizations/getOrganizationChoices.d.ts +6 -0
- package/dist/actions/organizations/getOrganizationChoices.js +23 -0
- package/dist/actions/organizations/getOrganizationChoices.js.map +1 -0
- package/dist/actions/organizations/getOrganizationsWithAttachGrantInfo.d.ts +2 -0
- package/dist/actions/organizations/getOrganizationsWithAttachGrantInfo.js +9 -0
- package/dist/actions/organizations/getOrganizationsWithAttachGrantInfo.js.map +1 -0
- package/dist/actions/organizations/hasProjectAttachGrant.d.ts +1 -0
- package/dist/actions/organizations/hasProjectAttachGrant.js +24 -0
- package/dist/actions/organizations/hasProjectAttachGrant.js.map +1 -0
- package/dist/actions/schema/deleteSchemaAction.d.ts +13 -5
- package/dist/actions/schema/deleteSchemaAction.js +12 -17
- package/dist/actions/schema/deleteSchemaAction.js.map +1 -1
- package/dist/actions/schema/deploySchemas.d.ts +15 -0
- package/dist/actions/schema/deploySchemas.js +98 -0
- package/dist/actions/schema/deploySchemas.js.map +1 -0
- package/dist/actions/schema/listSchemas.d.ts +12 -0
- package/dist/actions/schema/listSchemas.js +119 -0
- package/dist/actions/schema/listSchemas.js.map +1 -0
- package/dist/actions/schema/schemaStoreTypes.d.ts +0 -11
- package/dist/actions/schema/schemaStoreTypes.js.map +1 -1
- package/dist/actions/schema/utils/debug.d.ts +2 -0
- package/dist/actions/schema/utils/debug.js +5 -0
- package/dist/actions/schema/utils/debug.js.map +1 -0
- package/dist/actions/schema/utils/manifestExtractor.d.ts +3 -8
- package/dist/actions/schema/utils/manifestExtractor.js +12 -17
- package/dist/actions/schema/utils/manifestExtractor.js.map +1 -1
- package/dist/actions/schema/utils/manifestReader.d.ts +2 -9
- package/dist/actions/schema/utils/manifestReader.js +6 -12
- package/dist/actions/schema/utils/manifestReader.js.map +1 -1
- package/dist/actions/schema/utils/schemaStoreOutStrings.d.ts +0 -1
- package/dist/actions/schema/utils/schemaStoreOutStrings.js +1 -1
- package/dist/actions/schema/utils/schemaStoreOutStrings.js.map +1 -1
- package/dist/actions/schema/utils/schemaStoreValidation.d.ts +10 -62
- package/dist/actions/schema/utils/schemaStoreValidation.js +40 -127
- package/dist/actions/schema/utils/schemaStoreValidation.js.map +1 -1
- package/dist/actions/schema/utils/uniqByProjectIdDataset.d.ts +14 -0
- package/dist/actions/schema/utils/uniqByProjectIdDataset.js +9 -0
- package/dist/actions/schema/utils/uniqByProjectIdDataset.js.map +1 -0
- package/dist/actions/users/getMembersForProject.d.ts +1 -3
- package/dist/actions/users/getMembersForProject.js +6 -17
- package/dist/actions/users/getMembersForProject.js.map +1 -1
- package/dist/actions/users/types.d.ts +0 -11
- package/dist/actions/users/types.js.map +1 -1
- package/dist/commands/__tests__/debug.test.js +113 -220
- package/dist/commands/__tests__/debug.test.js.map +1 -1
- package/dist/commands/__tests__/deploy.test.js +325 -293
- package/dist/commands/__tests__/deploy.test.js.map +1 -1
- package/dist/commands/__tests__/dev.test.js +62 -19
- package/dist/commands/__tests__/dev.test.js.map +1 -1
- package/dist/commands/__tests__/init/init.authentication.test.js +73 -0
- package/dist/commands/__tests__/init/init.authentication.test.js.map +1 -0
- package/dist/commands/__tests__/init/init.create-new-project.test.js +195 -0
- package/dist/commands/__tests__/init/init.create-new-project.test.js.map +1 -0
- package/dist/commands/__tests__/init/init.plan.test.js +279 -0
- package/dist/commands/__tests__/init/init.plan.test.js.map +1 -0
- package/dist/commands/__tests__/init/init.setup.test.js +335 -0
- package/dist/commands/__tests__/init/init.setup.test.js.map +1 -0
- package/dist/commands/__tests__/install.test.js +46 -22
- package/dist/commands/__tests__/install.test.js.map +1 -1
- package/dist/commands/__tests__/logout.test.js +8 -5
- package/dist/commands/__tests__/logout.test.js.map +1 -1
- package/dist/commands/__tests__/manage.test.js +29 -24
- package/dist/commands/__tests__/manage.test.js.map +1 -1
- package/dist/commands/__tests__/migration.test.js +119 -0
- package/dist/commands/__tests__/migration.test.js.map +1 -0
- package/dist/commands/__tests__/versions.test.js +22 -14
- package/dist/commands/__tests__/versions.test.js.map +1 -1
- package/dist/commands/backup/__tests__/disable.test.js +72 -75
- package/dist/commands/backup/__tests__/disable.test.js.map +1 -1
- package/dist/commands/backup/__tests__/download.test.js +169 -80
- package/dist/commands/backup/__tests__/download.test.js.map +1 -1
- package/dist/commands/backup/__tests__/enable.test.js +109 -140
- package/dist/commands/backup/__tests__/enable.test.js.map +1 -1
- package/dist/commands/backup/__tests__/list.test.js +84 -75
- package/dist/commands/backup/__tests__/list.test.js.map +1 -1
- package/dist/commands/backup/disable.js +5 -11
- package/dist/commands/backup/disable.js.map +1 -1
- package/dist/commands/backup/enable.js +5 -11
- package/dist/commands/backup/enable.js.map +1 -1
- package/dist/commands/backup/list.js +7 -8
- package/dist/commands/backup/list.js.map +1 -1
- package/dist/commands/cors/__tests__/add.test.js +68 -38
- package/dist/commands/cors/__tests__/add.test.js.map +1 -1
- package/dist/commands/cors/__tests__/delete.test.js +52 -37
- package/dist/commands/cors/__tests__/delete.test.js.map +1 -1
- package/dist/commands/cors/__tests__/list.test.js +80 -57
- package/dist/commands/cors/__tests__/list.test.js.map +1 -1
- package/dist/commands/cors/add.js +5 -13
- package/dist/commands/cors/add.js.map +1 -1
- package/dist/commands/cors/delete.js +7 -15
- package/dist/commands/cors/delete.js.map +1 -1
- package/dist/commands/cors/list.js +2 -10
- package/dist/commands/cors/list.js.map +1 -1
- package/dist/commands/dataset/__tests__/copy.test.js +197 -89
- package/dist/commands/dataset/__tests__/copy.test.js.map +1 -1
- package/dist/commands/dataset/__tests__/create.test.js +147 -117
- package/dist/commands/dataset/__tests__/create.test.js.map +1 -1
- package/dist/commands/dataset/__tests__/delete.test.js +75 -68
- package/dist/commands/dataset/__tests__/delete.test.js.map +1 -1
- package/dist/commands/dataset/__tests__/export.test.js +123 -83
- package/dist/commands/dataset/__tests__/export.test.js.map +1 -1
- package/dist/commands/dataset/__tests__/import.test.js +2 -2
- package/dist/commands/dataset/__tests__/import.test.js.map +1 -1
- package/dist/commands/dataset/__tests__/list.test.js +107 -65
- package/dist/commands/dataset/__tests__/list.test.js.map +1 -1
- package/dist/commands/dataset/alias/__tests__/create.test.js +114 -74
- package/dist/commands/dataset/alias/__tests__/create.test.js.map +1 -1
- package/dist/commands/dataset/alias/__tests__/delete.test.js +40 -29
- package/dist/commands/dataset/alias/__tests__/delete.test.js.map +1 -1
- package/dist/commands/dataset/alias/__tests__/link.test.js +114 -74
- package/dist/commands/dataset/alias/__tests__/link.test.js.map +1 -1
- package/dist/commands/dataset/alias/__tests__/unlink.test.js +44 -29
- package/dist/commands/dataset/alias/__tests__/unlink.test.js.map +1 -1
- package/dist/commands/dataset/export.js +4 -4
- package/dist/commands/dataset/export.js.map +1 -1
- package/dist/commands/dataset/visibility/__tests__/get.test.js +48 -67
- package/dist/commands/dataset/visibility/__tests__/get.test.js.map +1 -1
- package/dist/commands/dataset/visibility/__tests__/set.test.js +76 -123
- package/dist/commands/dataset/visibility/__tests__/set.test.js.map +1 -1
- package/dist/commands/dev.js +0 -1
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/docs/__tests__/search.test.js +8 -7
- package/dist/commands/docs/__tests__/search.test.js.map +1 -1
- package/dist/commands/documents/__tests__/create.test.js +328 -265
- package/dist/commands/documents/__tests__/create.test.js.map +1 -1
- package/dist/commands/documents/__tests__/delete.test.js +119 -87
- package/dist/commands/documents/__tests__/delete.test.js.map +1 -1
- package/dist/commands/documents/__tests__/get.test.js +68 -95
- package/dist/commands/documents/__tests__/get.test.js.map +1 -1
- package/dist/commands/documents/__tests__/query.test.js +87 -192
- package/dist/commands/documents/__tests__/query.test.js.map +1 -1
- package/dist/commands/documents/__tests__/validate.test.js +52 -29
- package/dist/commands/documents/__tests__/validate.test.js.map +1 -1
- package/dist/commands/documents/create.d.ts +1 -0
- package/dist/commands/documents/create.js +10 -9
- package/dist/commands/documents/create.js.map +1 -1
- package/dist/commands/documents/delete.js +2 -3
- package/dist/commands/documents/delete.js.map +1 -1
- package/dist/commands/documents/get.js +2 -3
- package/dist/commands/documents/get.js.map +1 -1
- package/dist/commands/documents/query.js +2 -3
- package/dist/commands/documents/query.js.map +1 -1
- package/dist/commands/documents/validate.js +0 -20
- package/dist/commands/documents/validate.js.map +1 -1
- package/dist/commands/graphql/__tests__/list.test.js +57 -45
- package/dist/commands/graphql/__tests__/list.test.js.map +1 -1
- package/dist/commands/graphql/__tests__/undeploy.test.js +85 -59
- package/dist/commands/graphql/__tests__/undeploy.test.js.map +1 -1
- package/dist/commands/graphql/list.js +2 -2
- package/dist/commands/graphql/list.js.map +1 -1
- package/dist/commands/graphql/undeploy.js +4 -9
- package/dist/commands/graphql/undeploy.js.map +1 -1
- package/dist/commands/hook/__tests__/attempt.test.js +48 -33
- package/dist/commands/hook/__tests__/attempt.test.js.map +1 -1
- package/dist/commands/hook/__tests__/create.test.js +49 -51
- package/dist/commands/hook/__tests__/create.test.js.map +1 -1
- package/dist/commands/hook/__tests__/delete.test.js +43 -30
- package/dist/commands/hook/__tests__/delete.test.js.map +1 -1
- package/dist/commands/hook/__tests__/list.test.js +38 -31
- package/dist/commands/hook/__tests__/list.test.js.map +1 -1
- package/dist/commands/hook/__tests__/logs.test.js +68 -40
- package/dist/commands/hook/__tests__/logs.test.js.map +1 -1
- package/dist/commands/hook/create.js +2 -6
- package/dist/commands/hook/create.js.map +1 -1
- package/dist/commands/hook/delete.js +5 -17
- package/dist/commands/hook/delete.js.map +1 -1
- package/dist/commands/hook/list.js +2 -8
- package/dist/commands/hook/list.js.map +1 -1
- package/dist/commands/init.d.ts +4 -0
- package/dist/commands/init.js +151 -18
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/login.js +1 -1
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/manifest/__tests__/extract.test.js +22 -13
- package/dist/commands/manifest/__tests__/extract.test.js.map +1 -1
- package/dist/commands/media/__tests__/create-aspect.test.js +41 -28
- package/dist/commands/media/__tests__/create-aspect.test.js.map +1 -1
- package/dist/commands/media/__tests__/delete-aspect.test.js +44 -35
- package/dist/commands/media/__tests__/delete-aspect.test.js.map +1 -1
- package/dist/commands/media/__tests__/deploy-aspect.test.js +67 -80
- package/dist/commands/media/__tests__/deploy-aspect.test.js.map +1 -1
- package/dist/commands/media/__tests__/export.test.js +365 -66
- package/dist/commands/media/__tests__/export.test.js.map +1 -1
- package/dist/commands/media/__tests__/import.test.js +171 -105
- package/dist/commands/media/__tests__/import.test.js.map +1 -1
- package/dist/commands/media/export.js +2 -2
- package/dist/commands/media/export.js.map +1 -1
- package/dist/commands/media/import.js +2 -2
- package/dist/commands/media/import.js.map +1 -1
- package/dist/commands/projects/__tests__/list.test.js +5 -4
- package/dist/commands/projects/__tests__/list.test.js.map +1 -1
- package/dist/commands/projects/list.js +2 -6
- package/dist/commands/projects/list.js.map +1 -1
- package/dist/commands/schema/__tests__/delete.test.js +396 -151
- package/dist/commands/schema/__tests__/delete.test.js.map +1 -1
- package/dist/commands/schema/__tests__/deploy.test.js +348 -0
- package/dist/commands/schema/__tests__/deploy.test.js.map +1 -0
- package/dist/commands/schema/__tests__/extract.test.js +19 -11
- package/dist/commands/schema/__tests__/extract.test.js.map +1 -1
- package/dist/commands/schema/__tests__/list.test.js +399 -0
- package/dist/commands/schema/__tests__/list.test.js.map +1 -0
- package/dist/commands/schema/__tests__/validate.test.js +27 -10
- package/dist/commands/schema/__tests__/validate.test.js.map +1 -1
- package/dist/commands/schema/delete.d.ts +1 -1
- package/dist/commands/schema/delete.js +20 -23
- package/dist/commands/schema/delete.js.map +1 -1
- package/dist/commands/schema/deploy.d.ts +16 -0
- package/dist/commands/schema/deploy.js +98 -0
- package/dist/commands/schema/deploy.js.map +1 -0
- package/dist/commands/schema/list.d.ts +15 -0
- package/dist/commands/schema/list.js +104 -0
- package/dist/commands/schema/list.js.map +1 -0
- package/dist/commands/telemetry/__tests__/disable.test.js +7 -5
- package/dist/commands/telemetry/__tests__/disable.test.js.map +1 -1
- package/dist/commands/telemetry/__tests__/enable.test.js +7 -5
- package/dist/commands/telemetry/__tests__/enable.test.js.map +1 -1
- package/dist/commands/telemetry/__tests__/status.test.js +7 -5
- package/dist/commands/telemetry/__tests__/status.test.js.map +1 -1
- package/dist/commands/tokens/__tests__/add.test.js +55 -40
- package/dist/commands/tokens/__tests__/add.test.js.map +1 -1
- package/dist/commands/tokens/__tests__/delete.test.js +72 -42
- package/dist/commands/tokens/__tests__/delete.test.js.map +1 -1
- package/dist/commands/tokens/__tests__/list.test.js +87 -60
- package/dist/commands/tokens/__tests__/list.test.js.map +1 -1
- package/dist/commands/tokens/add.js +3 -5
- package/dist/commands/tokens/add.js.map +1 -1
- package/dist/commands/users/__tests__/invite.test.js +100 -79
- package/dist/commands/users/__tests__/invite.test.js.map +1 -1
- package/dist/commands/users/__tests__/list.test.js +186 -180
- package/dist/commands/users/__tests__/list.test.js.map +1 -1
- package/dist/commands/users/invite.js +6 -17
- package/dist/commands/users/invite.js.map +1 -1
- package/dist/commands/users/list.js +4 -7
- package/dist/commands/users/list.js.map +1 -1
- package/dist/config/createCliConfig.d.ts +4 -4
- package/dist/services/backup.d.ts +8 -0
- package/dist/services/backup.js +19 -0
- package/dist/services/backup.js.map +1 -1
- package/dist/services/cors.d.ts +23 -0
- package/dist/services/cors.js +38 -0
- package/dist/services/cors.js.map +1 -0
- package/dist/services/graphql.d.ts +7 -0
- package/dist/services/graphql.js +11 -0
- package/dist/services/graphql.js.map +1 -1
- package/dist/services/hooks.d.ts +2 -0
- package/dist/services/hooks.js +19 -0
- package/dist/services/hooks.js.map +1 -1
- package/dist/services/organizations.d.ts +40 -0
- package/dist/services/organizations.js +41 -0
- package/dist/services/organizations.js.map +1 -0
- package/dist/services/projects.d.ts +31 -0
- package/dist/services/projects.js +71 -1
- package/dist/services/projects.js.map +1 -1
- package/dist/services/schemas.d.ts +4 -0
- package/dist/services/schemas.js +40 -0
- package/dist/services/schemas.js.map +1 -0
- package/dist/services/user.d.ts +10 -0
- package/dist/services/user.js +24 -0
- package/dist/services/user.js.map +1 -0
- package/dist/util/__tests__/getCliVersion.test.js +2 -2
- package/dist/util/__tests__/getCliVersion.test.js.map +1 -1
- package/dist/util/errorMessages.d.ts +1 -0
- package/dist/util/errorMessages.js +1 -0
- package/dist/util/errorMessages.js.map +1 -1
- package/dist/util/getCliVersion.js +1 -1
- package/dist/util/getCliVersion.js.map +1 -1
- package/dist/util/readPackageJson.d.ts +1 -15
- package/dist/util/readPackageJson.js +1 -1
- package/dist/util/readPackageJson.js.map +1 -1
- package/dist/util/uniqBy.d.ts +1 -0
- package/dist/util/uniqBy.js +14 -0
- package/dist/util/uniqBy.js.map +1 -0
- package/oclif.config.js +6 -1
- package/oclif.manifest.json +152 -158
- package/package.json +30 -31
- package/dist/actions/cors/constants.d.ts +0 -1
- package/dist/actions/cors/constants.js +0 -3
- package/dist/actions/cors/constants.js.map +0 -1
- package/dist/actions/cors/types.d.ts +0 -9
- package/dist/actions/cors/types.js +0 -3
- package/dist/actions/cors/types.js.map +0 -1
- package/dist/actions/migration/getMigrationRootDirectory.d.ts +0 -2
- package/dist/actions/migration/getMigrationRootDirectory.js +0 -14
- package/dist/actions/migration/getMigrationRootDirectory.js.map +0 -1
- package/dist/actions/migration/resolveMigrations.d.ts +0 -19
- package/dist/actions/migration/resolveMigrations.js +0 -43
- package/dist/actions/migration/resolveMigrations.js.map +0 -1
- package/dist/actions/migration/templates/__tests__/minimalAdvanced.test.js +0 -65
- package/dist/actions/migration/templates/__tests__/minimalAdvanced.test.js.map +0 -1
- package/dist/actions/migration/templates/__tests__/minimalSimple.test.js +0 -145
- package/dist/actions/migration/templates/__tests__/minimalSimple.test.js.map +0 -1
- package/dist/actions/migration/templates/__tests__/renameField.test.js +0 -63
- package/dist/actions/migration/templates/__tests__/renameField.test.js.map +0 -1
- package/dist/actions/migration/templates/__tests__/renameType.test.js +0 -61
- package/dist/actions/migration/templates/__tests__/renameType.test.js.map +0 -1
- package/dist/actions/migration/templates/__tests__/stringToPTE.test.js +0 -87
- package/dist/actions/migration/templates/__tests__/stringToPTE.test.js.map +0 -1
- package/dist/actions/migration/templates/index.d.ts +0 -5
- package/dist/actions/migration/templates/index.js +0 -7
- package/dist/actions/migration/templates/index.js.map +0 -1
- package/dist/actions/migration/templates/minimalAdvanced.d.ts +0 -4
- package/dist/actions/migration/templates/minimalAdvanced.js +0 -21
- package/dist/actions/migration/templates/minimalAdvanced.js.map +0 -1
- package/dist/actions/migration/templates/minimalSimple.d.ts +0 -4
- package/dist/actions/migration/templates/minimalSimple.js +0 -61
- package/dist/actions/migration/templates/minimalSimple.js.map +0 -1
- package/dist/actions/migration/templates/renameField.d.ts +0 -4
- package/dist/actions/migration/templates/renameField.js +0 -20
- package/dist/actions/migration/templates/renameField.js.map +0 -1
- package/dist/actions/migration/templates/renameType.d.ts +0 -4
- package/dist/actions/migration/templates/renameType.js +0 -19
- package/dist/actions/migration/templates/renameType.js.map +0 -1
- package/dist/actions/migration/templates/stringToPTE.d.ts +0 -4
- package/dist/actions/migration/templates/stringToPTE.js +0 -32
- package/dist/actions/migration/templates/stringToPTE.js.map +0 -1
- package/dist/actions/schema/__tests__/deleteSchemaAction.test.js +0 -294
- package/dist/actions/schema/__tests__/deleteSchemaAction.test.js.map +0 -1
- package/dist/actions/schema/schemaStoreConstants.d.ts +0 -1
- package/dist/actions/schema/schemaStoreConstants.js +0 -4
- package/dist/actions/schema/schemaStoreConstants.js.map +0 -1
- package/dist/actions/schema/utils/schemaActionHelpers.d.ts +0 -1
- package/dist/actions/schema/utils/schemaActionHelpers.js +0 -5
- package/dist/actions/schema/utils/schemaActionHelpers.js.map +0 -1
- package/dist/actions/schema/utils/schemaApiClient.d.ts +0 -6
- package/dist/actions/schema/utils/schemaApiClient.js +0 -17
- package/dist/actions/schema/utils/schemaApiClient.js.map +0 -1
- package/dist/actions/users/apiVersion.d.ts +0 -6
- package/dist/actions/users/apiVersion.js +0 -7
- package/dist/actions/users/apiVersion.js.map +0 -1
- package/dist/commands/__tests__/init.test.js +0 -411
- package/dist/commands/__tests__/init.test.js.map +0 -1
- package/dist/commands/migration/__tests__/create.test.js +0 -296
- package/dist/commands/migration/__tests__/create.test.js.map +0 -1
- package/dist/commands/migration/__tests__/list.test.js +0 -166
- package/dist/commands/migration/__tests__/list.test.js.map +0 -1
- package/dist/commands/migration/__tests__/run.test.js +0 -481
- package/dist/commands/migration/__tests__/run.test.js.map +0 -1
- package/dist/commands/migration/create.d.ts +0 -17
- package/dist/commands/migration/create.js +0 -143
- package/dist/commands/migration/create.js.map +0 -1
- package/dist/commands/migration/list.d.ts +0 -9
- package/dist/commands/migration/list.js +0 -61
- package/dist/commands/migration/list.js.map +0 -1
- package/dist/commands/migration/run.d.ts +0 -26
- package/dist/commands/migration/run.js +0 -271
- package/dist/commands/migration/run.js.map +0 -1
- package/dist/util/migration/constants.d.ts +0 -3
- package/dist/util/migration/constants.js +0 -10
- package/dist/util/migration/constants.js.map +0 -1
- package/dist/util/migration/ensureApiVersionFormat.d.ts +0 -9
- package/dist/util/migration/ensureApiVersionFormat.js +0 -16
- package/dist/util/migration/ensureApiVersionFormat.js.map +0 -1
- package/dist/util/migration/prettyMutationFormatter.d.ts +0 -8
- package/dist/util/migration/prettyMutationFormatter.js +0 -141
- package/dist/util/migration/prettyMutationFormatter.js.map +0 -1
- package/dist/utils/migration/resolveMigrationScript.d.ts +0 -44
- package/dist/utils/migration/resolveMigrationScript.js +0 -74
- package/dist/utils/migration/resolveMigrationScript.js.map +0 -1
- /package/dist/actions/auth/login/{index.d.ts → login.d.ts} +0 -0
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from 'vitest';
|
|
2
|
-
import { stringToPTE } from '../stringToPTE';
|
|
3
|
-
describe('#stringToPTE', ()=>{
|
|
4
|
-
test('creates template with no doc types', ()=>{
|
|
5
|
-
const stringToPTETemplate = stringToPTE({
|
|
6
|
-
documentTypes: [],
|
|
7
|
-
migrationName: 'My Migration'
|
|
8
|
-
});
|
|
9
|
-
expect(stringToPTETemplate).toMatchInlineSnapshot(`
|
|
10
|
-
"import {pathsAreEqual, stringToPath} from 'sanity'
|
|
11
|
-
import {defineMigration, set} from '@sanity/migrate'
|
|
12
|
-
|
|
13
|
-
const targetPath = stringToPath('some.path')
|
|
14
|
-
|
|
15
|
-
export default defineMigration({
|
|
16
|
-
title: "My Migration",
|
|
17
|
-
|
|
18
|
-
migrate: {
|
|
19
|
-
string(node, path, ctx) {
|
|
20
|
-
if (pathsAreEqual(path, targetPath)) {
|
|
21
|
-
return set([
|
|
22
|
-
{
|
|
23
|
-
style: 'normal',
|
|
24
|
-
_type: 'block',
|
|
25
|
-
children: [
|
|
26
|
-
{
|
|
27
|
-
_type: 'span',
|
|
28
|
-
marks: [],
|
|
29
|
-
text: node,
|
|
30
|
-
},
|
|
31
|
-
],
|
|
32
|
-
markDefs: [],
|
|
33
|
-
},
|
|
34
|
-
])
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
})
|
|
39
|
-
"
|
|
40
|
-
`);
|
|
41
|
-
});
|
|
42
|
-
test('creates template with doc types', ()=>{
|
|
43
|
-
const stringToPTETemplate = stringToPTE({
|
|
44
|
-
documentTypes: [
|
|
45
|
-
'document-1',
|
|
46
|
-
'document-2',
|
|
47
|
-
'document-3'
|
|
48
|
-
],
|
|
49
|
-
migrationName: 'My Migration'
|
|
50
|
-
});
|
|
51
|
-
expect(stringToPTETemplate).toMatchInlineSnapshot(`
|
|
52
|
-
"import {pathsAreEqual, stringToPath} from 'sanity'
|
|
53
|
-
import {defineMigration, set} from '@sanity/migrate'
|
|
54
|
-
|
|
55
|
-
const targetPath = stringToPath('some.path')
|
|
56
|
-
|
|
57
|
-
export default defineMigration({
|
|
58
|
-
title: "My Migration",
|
|
59
|
-
documentTypes: ["document-1", "document-2", "document-3"],
|
|
60
|
-
|
|
61
|
-
migrate: {
|
|
62
|
-
string(node, path, ctx) {
|
|
63
|
-
if (pathsAreEqual(path, targetPath)) {
|
|
64
|
-
return set([
|
|
65
|
-
{
|
|
66
|
-
style: 'normal',
|
|
67
|
-
_type: 'block',
|
|
68
|
-
children: [
|
|
69
|
-
{
|
|
70
|
-
_type: 'span',
|
|
71
|
-
marks: [],
|
|
72
|
-
text: node,
|
|
73
|
-
},
|
|
74
|
-
],
|
|
75
|
-
markDefs: [],
|
|
76
|
-
},
|
|
77
|
-
])
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
})
|
|
82
|
-
"
|
|
83
|
-
`);
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
//# sourceMappingURL=stringToPTE.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/actions/migration/templates/__tests__/stringToPTE.test.ts"],"sourcesContent":["import {describe, expect, test} from 'vitest'\n\nimport {stringToPTE} from '../stringToPTE'\n\ndescribe('#stringToPTE', () => {\n test('creates template with no doc types', () => {\n const stringToPTETemplate = stringToPTE({\n documentTypes: [],\n migrationName: 'My Migration',\n })\n\n expect(stringToPTETemplate).toMatchInlineSnapshot(`\n \"import {pathsAreEqual, stringToPath} from 'sanity'\n import {defineMigration, set} from '@sanity/migrate'\n\n const targetPath = stringToPath('some.path')\n\n export default defineMigration({\n title: \"My Migration\",\n\n migrate: {\n string(node, path, ctx) {\n if (pathsAreEqual(path, targetPath)) {\n return set([\n {\n style: 'normal',\n _type: 'block',\n children: [\n {\n _type: 'span',\n marks: [],\n text: node,\n },\n ],\n markDefs: [],\n },\n ])\n }\n },\n },\n })\n \"\n `)\n })\n\n test('creates template with doc types', () => {\n const stringToPTETemplate = stringToPTE({\n documentTypes: ['document-1', 'document-2', 'document-3'],\n migrationName: 'My Migration',\n })\n\n expect(stringToPTETemplate).toMatchInlineSnapshot(`\n \"import {pathsAreEqual, stringToPath} from 'sanity'\n import {defineMigration, set} from '@sanity/migrate'\n\n const targetPath = stringToPath('some.path')\n\n export default defineMigration({\n title: \"My Migration\",\n documentTypes: [\"document-1\", \"document-2\", \"document-3\"],\n\n migrate: {\n string(node, path, ctx) {\n if (pathsAreEqual(path, targetPath)) {\n return set([\n {\n style: 'normal',\n _type: 'block',\n children: [\n {\n _type: 'span',\n marks: [],\n text: node,\n },\n ],\n markDefs: [],\n },\n ])\n }\n },\n },\n })\n \"\n `)\n })\n})\n"],"names":["describe","expect","test","stringToPTE","stringToPTETemplate","documentTypes","migrationName","toMatchInlineSnapshot"],"mappings":"AAAA,SAAQA,QAAQ,EAAEC,MAAM,EAAEC,IAAI,QAAO,SAAQ;AAE7C,SAAQC,WAAW,QAAO,iBAAgB;AAE1CH,SAAS,gBAAgB;IACvBE,KAAK,sCAAsC;QACzC,MAAME,sBAAsBD,YAAY;YACtCE,eAAe,EAAE;YACjBC,eAAe;QACjB;QAEAL,OAAOG,qBAAqBG,qBAAqB,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA+BnD,CAAC;IACH;IAEAL,KAAK,mCAAmC;QACtC,MAAME,sBAAsBD,YAAY;YACtCE,eAAe;gBAAC;gBAAc;gBAAc;aAAa;YACzDC,eAAe;QACjB;QAEAL,OAAOG,qBAAqBG,qBAAqB,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAgCnD,CAAC;IACH;AACF"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export { minimalAdvanced } from './minimalAdvanced.js';
|
|
2
|
-
export { minimalSimple } from './minimalSimple.js';
|
|
3
|
-
export { renameField } from './renameField.js';
|
|
4
|
-
export { renameType } from './renameType.js';
|
|
5
|
-
export { stringToPTE } from './stringToPTE.js';
|
|
6
|
-
|
|
7
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/actions/migration/templates/index.ts"],"sourcesContent":["export {minimalAdvanced} from './minimalAdvanced.js'\nexport {minimalSimple} from './minimalSimple.js'\nexport {renameField} from './renameField.js'\nexport {renameType} from './renameType.js'\nexport {stringToPTE} from './stringToPTE.js'\n"],"names":["minimalAdvanced","minimalSimple","renameField","renameType","stringToPTE"],"mappings":"AAAA,SAAQA,eAAe,QAAO,uBAAsB;AACpD,SAAQC,aAAa,QAAO,qBAAoB;AAChD,SAAQC,WAAW,QAAO,mBAAkB;AAC5C,SAAQC,UAAU,QAAO,kBAAiB;AAC1C,SAAQC,WAAW,QAAO,mBAAkB"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export const minimalAdvanced = ({ documentTypes, migrationName })=>`import {defineMigration, patch, at, setIfMissing} from '@sanity/migrate'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* this migration will set \`Default title\` on all documents that are missing a title
|
|
5
|
-
* and make \`true\` the default value for the \`enabled\` field
|
|
6
|
-
*/
|
|
7
|
-
export default defineMigration({
|
|
8
|
-
title: ${JSON.stringify(migrationName)},
|
|
9
|
-
${documentTypes.length > 0 ? ` documentTypes: [${documentTypes.map((t)=>JSON.stringify(t)).join(', ')}],\n` : ''}
|
|
10
|
-
async *migrate(documents, context) {
|
|
11
|
-
for await (const document of documents()) {
|
|
12
|
-
yield patch(document._id, [
|
|
13
|
-
at('title', setIfMissing('Default title')),
|
|
14
|
-
at('enabled', setIfMissing(true)),
|
|
15
|
-
])
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
})
|
|
19
|
-
`;
|
|
20
|
-
|
|
21
|
-
//# sourceMappingURL=minimalAdvanced.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/actions/migration/templates/minimalAdvanced.ts"],"sourcesContent":["export const minimalAdvanced = ({\n documentTypes,\n migrationName,\n}: {\n documentTypes: string[]\n migrationName: string\n}) => `import {defineMigration, patch, at, setIfMissing} from '@sanity/migrate'\n\n/**\n * this migration will set \\`Default title\\` on all documents that are missing a title\n * and make \\`true\\` the default value for the \\`enabled\\` field\n */\nexport default defineMigration({\n title: ${JSON.stringify(migrationName)},\n${\n documentTypes.length > 0\n ? ` documentTypes: [${documentTypes.map((t) => JSON.stringify(t)).join(', ')}],\\n`\n : ''\n}\n async *migrate(documents, context) {\n for await (const document of documents()) {\n yield patch(document._id, [\n at('title', setIfMissing('Default title')),\n at('enabled', setIfMissing(true)),\n ])\n }\n }\n})\n`\n"],"names":["minimalAdvanced","documentTypes","migrationName","JSON","stringify","length","map","t","join"],"mappings":"AAAA,OAAO,MAAMA,kBAAkB,CAAC,EAC9BC,aAAa,EACbC,aAAa,EAId,GAAK,CAAC;;;;;;;SAOE,EAAEC,KAAKC,SAAS,CAACF,eAAe;AACzC,EACED,cAAcI,MAAM,GAAG,IACnB,CAAC,kBAAkB,EAAEJ,cAAcK,GAAG,CAAC,CAACC,IAAMJ,KAAKC,SAAS,CAACG,IAAIC,IAAI,CAAC,MAAM,IAAI,CAAC,GACjF,GACL;;;;;;;;;;AAUD,CAAC,CAAA"}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
export const minimalSimple = ({ documentTypes, migrationName })=>`import {at, defineMigration, setIfMissing, unset} from '@sanity/migrate'
|
|
2
|
-
|
|
3
|
-
export default defineMigration({
|
|
4
|
-
title: ${JSON.stringify(migrationName)},
|
|
5
|
-
${documentTypes.length > 0 ? ` documentTypes: [${documentTypes.map((t)=>JSON.stringify(t)).join(', ')}],\n` : ''}
|
|
6
|
-
migrate: {
|
|
7
|
-
document(doc, context) {
|
|
8
|
-
// this will be called for every document of the matching type
|
|
9
|
-
// any patch returned will be applied to the document
|
|
10
|
-
// you can also return mutations that touches other documents
|
|
11
|
-
|
|
12
|
-
return at('title', setIfMissing('Default title'))
|
|
13
|
-
},
|
|
14
|
-
node(node, path, context) {
|
|
15
|
-
// this will be called for every node in every document of the matching type
|
|
16
|
-
// any patch returned will be applied to the document
|
|
17
|
-
// you can also return mutations that touches other documents
|
|
18
|
-
|
|
19
|
-
if (typeof node === 'string' && node === 'deleteme') {
|
|
20
|
-
return unset()
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
object(node, path, context) {
|
|
24
|
-
// this will be called for every object node in every document of the matching type
|
|
25
|
-
// any patch returned will be applied to the document
|
|
26
|
-
// you can also return mutations that touches other documents
|
|
27
|
-
if (node._type === 'author') {
|
|
28
|
-
// make sure all authors objects have a books array
|
|
29
|
-
return at('books', setIfMissing([]))
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
array(node, path, context) {
|
|
33
|
-
// this will be called for every array node in every document of the matching type
|
|
34
|
-
// any patch returned will be applied to the document
|
|
35
|
-
// you can also return mutations that touches other documents
|
|
36
|
-
},
|
|
37
|
-
string(node, path, context) {
|
|
38
|
-
// this will be called for every string node in every document of the matching type
|
|
39
|
-
// any patch returned will be applied to the document
|
|
40
|
-
// you can also return mutations that touches other documents
|
|
41
|
-
},
|
|
42
|
-
number(node, path, context) {
|
|
43
|
-
// this will be called for every number node in every document of the matching type
|
|
44
|
-
// any patch returned will be applied to the document
|
|
45
|
-
// you can also return mutations that touches other documents
|
|
46
|
-
},
|
|
47
|
-
boolean(node, path, context) {
|
|
48
|
-
// this will be called for every boolean node in every document of the matching type
|
|
49
|
-
// any patch returned will be applied to the document
|
|
50
|
-
// you can also return mutations that touches other documents
|
|
51
|
-
},
|
|
52
|
-
null(node, path, context) {
|
|
53
|
-
// this will be called for every null node in every document of the matching type
|
|
54
|
-
// any patch returned will be applied to the document
|
|
55
|
-
// you can also return mutations that touches other documents
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
})
|
|
59
|
-
`;
|
|
60
|
-
|
|
61
|
-
//# sourceMappingURL=minimalSimple.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/actions/migration/templates/minimalSimple.ts"],"sourcesContent":["export const minimalSimple = ({\n documentTypes,\n migrationName,\n}: {\n documentTypes: string[]\n migrationName: string\n}) => `import {at, defineMigration, setIfMissing, unset} from '@sanity/migrate'\n\nexport default defineMigration({\n title: ${JSON.stringify(migrationName)},\n${\n documentTypes.length > 0\n ? ` documentTypes: [${documentTypes.map((t) => JSON.stringify(t)).join(', ')}],\\n`\n : ''\n}\n migrate: {\n document(doc, context) {\n // this will be called for every document of the matching type\n // any patch returned will be applied to the document\n // you can also return mutations that touches other documents\n\n return at('title', setIfMissing('Default title'))\n },\n node(node, path, context) {\n // this will be called for every node in every document of the matching type\n // any patch returned will be applied to the document\n // you can also return mutations that touches other documents\n\n if (typeof node === 'string' && node === 'deleteme') {\n return unset()\n }\n },\n object(node, path, context) {\n // this will be called for every object node in every document of the matching type\n // any patch returned will be applied to the document\n // you can also return mutations that touches other documents\n if (node._type === 'author') {\n // make sure all authors objects have a books array\n return at('books', setIfMissing([]))\n }\n },\n array(node, path, context) {\n // this will be called for every array node in every document of the matching type\n // any patch returned will be applied to the document\n // you can also return mutations that touches other documents\n },\n string(node, path, context) {\n // this will be called for every string node in every document of the matching type\n // any patch returned will be applied to the document\n // you can also return mutations that touches other documents\n },\n number(node, path, context) {\n // this will be called for every number node in every document of the matching type\n // any patch returned will be applied to the document\n // you can also return mutations that touches other documents\n },\n boolean(node, path, context) {\n // this will be called for every boolean node in every document of the matching type\n // any patch returned will be applied to the document\n // you can also return mutations that touches other documents\n },\n null(node, path, context) {\n // this will be called for every null node in every document of the matching type\n // any patch returned will be applied to the document\n // you can also return mutations that touches other documents\n },\n },\n})\n`\n"],"names":["minimalSimple","documentTypes","migrationName","JSON","stringify","length","map","t","join"],"mappings":"AAAA,OAAO,MAAMA,gBAAgB,CAAC,EAC5BC,aAAa,EACbC,aAAa,EAId,GAAK,CAAC;;;SAGE,EAAEC,KAAKC,SAAS,CAACF,eAAe;AACzC,EACED,cAAcI,MAAM,GAAG,IACnB,CAAC,kBAAkB,EAAEJ,cAAcK,GAAG,CAAC,CAACC,IAAMJ,KAAKC,SAAS,CAACG,IAAIC,IAAI,CAAC,MAAM,IAAI,CAAC,GACjF,GACL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsDD,CAAC,CAAA"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export const renameField = ({ documentTypes, migrationName })=>`import {defineMigration, at, setIfMissing, unset} from '@sanity/migrate'
|
|
2
|
-
|
|
3
|
-
const from = 'oldFieldName'
|
|
4
|
-
const to = 'newFieldName'
|
|
5
|
-
|
|
6
|
-
export default defineMigration({
|
|
7
|
-
title: ${JSON.stringify(migrationName)},
|
|
8
|
-
${documentTypes.length > 0 ? ` documentTypes: [${documentTypes.map((t)=>JSON.stringify(t)).join(', ')}],\n` : ''}
|
|
9
|
-
migrate: {
|
|
10
|
-
document(doc, context) {
|
|
11
|
-
return [
|
|
12
|
-
at(to, setIfMissing(doc[from])),
|
|
13
|
-
at(from, unset())
|
|
14
|
-
]
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
})
|
|
18
|
-
`;
|
|
19
|
-
|
|
20
|
-
//# sourceMappingURL=renameField.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/actions/migration/templates/renameField.ts"],"sourcesContent":["export const renameField = ({\n documentTypes,\n migrationName,\n}: {\n documentTypes: string[]\n migrationName: string\n}) => `import {defineMigration, at, setIfMissing, unset} from '@sanity/migrate'\n\nconst from = 'oldFieldName'\nconst to = 'newFieldName'\n\nexport default defineMigration({\n title: ${JSON.stringify(migrationName)},\n${\n documentTypes.length > 0\n ? ` documentTypes: [${documentTypes.map((t) => JSON.stringify(t)).join(', ')}],\\n`\n : ''\n}\n migrate: {\n document(doc, context) {\n return [\n at(to, setIfMissing(doc[from])),\n at(from, unset())\n ]\n }\n }\n})\n`\n"],"names":["renameField","documentTypes","migrationName","JSON","stringify","length","map","t","join"],"mappings":"AAAA,OAAO,MAAMA,cAAc,CAAC,EAC1BC,aAAa,EACbC,aAAa,EAId,GAAK,CAAC;;;;;;SAME,EAAEC,KAAKC,SAAS,CAACF,eAAe;AACzC,EACED,cAAcI,MAAM,GAAG,IACnB,CAAC,kBAAkB,EAAEJ,cAAcK,GAAG,CAAC,CAACC,IAAMJ,KAAKC,SAAS,CAACG,IAAIC,IAAI,CAAC,MAAM,IAAI,CAAC,GACjF,GACL;;;;;;;;;;AAUD,CAAC,CAAA"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export const renameType = ({ documentTypes, migrationName })=>`import {defineMigration, at, set} from '@sanity/migrate'
|
|
2
|
-
|
|
3
|
-
const oldType = 'old'
|
|
4
|
-
const newType = 'new'
|
|
5
|
-
|
|
6
|
-
export default defineMigration({
|
|
7
|
-
title: ${JSON.stringify(migrationName)},
|
|
8
|
-
${documentTypes.length > 0 ? ` documentTypes: [${documentTypes.map((t)=>JSON.stringify(t)).join(', ')}],\n` : ''}
|
|
9
|
-
migrate: {
|
|
10
|
-
object(object, path, context) {
|
|
11
|
-
if (object._type === oldType) {
|
|
12
|
-
return at('_type', set(newType))
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
})
|
|
17
|
-
`;
|
|
18
|
-
|
|
19
|
-
//# sourceMappingURL=renameType.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/actions/migration/templates/renameType.ts"],"sourcesContent":["export const renameType = ({\n documentTypes,\n migrationName,\n}: {\n documentTypes: string[]\n migrationName: string\n}) => `import {defineMigration, at, set} from '@sanity/migrate'\n\nconst oldType = 'old'\nconst newType = 'new'\n\nexport default defineMigration({\n title: ${JSON.stringify(migrationName)},\n${\n documentTypes.length > 0\n ? ` documentTypes: [${documentTypes.map((t) => JSON.stringify(t)).join(', ')}],\\n`\n : ''\n}\n migrate: {\n object(object, path, context) {\n if (object._type === oldType) {\n return at('_type', set(newType))\n }\n }\n }\n})\n`\n"],"names":["renameType","documentTypes","migrationName","JSON","stringify","length","map","t","join"],"mappings":"AAAA,OAAO,MAAMA,aAAa,CAAC,EACzBC,aAAa,EACbC,aAAa,EAId,GAAK,CAAC;;;;;;SAME,EAAEC,KAAKC,SAAS,CAACF,eAAe;AACzC,EACED,cAAcI,MAAM,GAAG,IACnB,CAAC,kBAAkB,EAAEJ,cAAcK,GAAG,CAAC,CAACC,IAAMJ,KAAKC,SAAS,CAACG,IAAIC,IAAI,CAAC,MAAM,IAAI,CAAC,GACjF,GACL;;;;;;;;;AASD,CAAC,CAAA"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export const stringToPTE = ({ documentTypes, migrationName })=>`import {pathsAreEqual, stringToPath} from 'sanity'
|
|
2
|
-
import {defineMigration, set} from '@sanity/migrate'
|
|
3
|
-
|
|
4
|
-
const targetPath = stringToPath('some.path')
|
|
5
|
-
|
|
6
|
-
export default defineMigration({
|
|
7
|
-
title: ${JSON.stringify(migrationName)},
|
|
8
|
-
${documentTypes.length > 0 ? ` documentTypes: [${documentTypes.map((t)=>JSON.stringify(t)).join(', ')}],\n` : ''}
|
|
9
|
-
migrate: {
|
|
10
|
-
string(node, path, ctx) {
|
|
11
|
-
if (pathsAreEqual(path, targetPath)) {
|
|
12
|
-
return set([
|
|
13
|
-
{
|
|
14
|
-
style: 'normal',
|
|
15
|
-
_type: 'block',
|
|
16
|
-
children: [
|
|
17
|
-
{
|
|
18
|
-
_type: 'span',
|
|
19
|
-
marks: [],
|
|
20
|
-
text: node,
|
|
21
|
-
},
|
|
22
|
-
],
|
|
23
|
-
markDefs: [],
|
|
24
|
-
},
|
|
25
|
-
])
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
})
|
|
30
|
-
`;
|
|
31
|
-
|
|
32
|
-
//# sourceMappingURL=stringToPTE.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/actions/migration/templates/stringToPTE.ts"],"sourcesContent":["export const stringToPTE = ({\n documentTypes,\n migrationName,\n}: {\n documentTypes: string[]\n migrationName: string\n}) => `import {pathsAreEqual, stringToPath} from 'sanity'\nimport {defineMigration, set} from '@sanity/migrate'\n\nconst targetPath = stringToPath('some.path')\n\nexport default defineMigration({\n title: ${JSON.stringify(migrationName)},\n${\n documentTypes.length > 0\n ? ` documentTypes: [${documentTypes.map((t) => JSON.stringify(t)).join(', ')}],\\n`\n : ''\n}\n migrate: {\n string(node, path, ctx) {\n if (pathsAreEqual(path, targetPath)) {\n return set([\n {\n style: 'normal',\n _type: 'block',\n children: [\n {\n _type: 'span',\n marks: [],\n text: node,\n },\n ],\n markDefs: [],\n },\n ])\n }\n },\n },\n})\n`\n"],"names":["stringToPTE","documentTypes","migrationName","JSON","stringify","length","map","t","join"],"mappings":"AAAA,OAAO,MAAMA,cAAc,CAAC,EAC1BC,aAAa,EACbC,aAAa,EAId,GAAK,CAAC;;;;;;SAME,EAAEC,KAAKC,SAAS,CAACF,eAAe;AACzC,EACED,cAAcI,MAAM,GAAG,IACnB,CAAC,kBAAkB,EAAEJ,cAAcK,GAAG,CAAC,CAACC,IAAMJ,KAAKC,SAAS,CAACG,IAAIC,IAAI,CAAC,MAAM,IAAI,CAAC,GACjF,GACL;;;;;;;;;;;;;;;;;;;;;;AAsBD,CAAC,CAAA"}
|
|
@@ -1,294 +0,0 @@
|
|
|
1
|
-
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
|
|
2
|
-
import { deleteSchemaAction } from '../deleteSchemaAction';
|
|
3
|
-
// Mock dependencies
|
|
4
|
-
const mockOutput = {
|
|
5
|
-
error: vi.fn(),
|
|
6
|
-
log: vi.fn(),
|
|
7
|
-
warn: vi.fn()
|
|
8
|
-
};
|
|
9
|
-
const mockApiClient = vi.fn();
|
|
10
|
-
const mockJsonReader = vi.fn();
|
|
11
|
-
const mockManifestExtractor = vi.fn();
|
|
12
|
-
const mockManifest = {
|
|
13
|
-
createdAt: '2024-01-01T00:00:00.000Z',
|
|
14
|
-
studioVersion: '3.0.0',
|
|
15
|
-
version: 3,
|
|
16
|
-
workspaces: [
|
|
17
|
-
{
|
|
18
|
-
basePath: '/',
|
|
19
|
-
dataset: 'production',
|
|
20
|
-
icon: null,
|
|
21
|
-
name: 'default',
|
|
22
|
-
projectId: 'test-project',
|
|
23
|
-
schema: 'default.create-schema.json',
|
|
24
|
-
tools: 'default.create-tools.json'
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
basePath: '/staging',
|
|
28
|
-
dataset: 'staging',
|
|
29
|
-
icon: null,
|
|
30
|
-
name: 'staging',
|
|
31
|
-
projectId: 'test-project',
|
|
32
|
-
schema: 'staging.create-schema.json',
|
|
33
|
-
tools: 'staging.create-tools.json'
|
|
34
|
-
}
|
|
35
|
-
]
|
|
36
|
-
};
|
|
37
|
-
describe('deleteSchemaAction', ()=>{
|
|
38
|
-
let context;
|
|
39
|
-
let mockClientWithConfig;
|
|
40
|
-
beforeEach(()=>{
|
|
41
|
-
// Reset all mocks
|
|
42
|
-
vi.clearAllMocks();
|
|
43
|
-
// Setup client with config mock - needs withConfig for chaining
|
|
44
|
-
mockClientWithConfig = {
|
|
45
|
-
config: vi.fn().mockReturnValue({
|
|
46
|
-
dataset: 'production',
|
|
47
|
-
projectId: 'test-project'
|
|
48
|
-
}),
|
|
49
|
-
delete: vi.fn().mockResolvedValue({
|
|
50
|
-
results: [
|
|
51
|
-
{
|
|
52
|
-
id: 'test-id'
|
|
53
|
-
}
|
|
54
|
-
]
|
|
55
|
-
}),
|
|
56
|
-
withConfig: vi.fn()
|
|
57
|
-
};
|
|
58
|
-
// Make withConfig return itself for chaining
|
|
59
|
-
mockClientWithConfig.withConfig.mockReturnValue(mockClientWithConfig);
|
|
60
|
-
// Setup API client to return a client that has withConfig
|
|
61
|
-
mockApiClient.mockResolvedValue({
|
|
62
|
-
config: vi.fn().mockReturnValue({
|
|
63
|
-
dataset: 'production',
|
|
64
|
-
projectId: 'test-project'
|
|
65
|
-
}),
|
|
66
|
-
withConfig: vi.fn().mockReturnValue(mockClientWithConfig)
|
|
67
|
-
});
|
|
68
|
-
mockManifestExtractor.mockResolvedValue(undefined);
|
|
69
|
-
mockJsonReader.mockImplementation(async (filePath)=>{
|
|
70
|
-
if (filePath.includes('create-manifest.json')) {
|
|
71
|
-
return {
|
|
72
|
-
lastModified: '2024-01-01T00:00:00.000Z',
|
|
73
|
-
parsedJson: mockManifest,
|
|
74
|
-
path: filePath
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
return undefined;
|
|
78
|
-
});
|
|
79
|
-
// Setup default context
|
|
80
|
-
context = {
|
|
81
|
-
apiClient: mockApiClient,
|
|
82
|
-
jsonReader: mockJsonReader,
|
|
83
|
-
manifestExtractor: mockManifestExtractor,
|
|
84
|
-
output: mockOutput,
|
|
85
|
-
workDir: '/test/path'
|
|
86
|
-
};
|
|
87
|
-
});
|
|
88
|
-
afterEach(()=>{
|
|
89
|
-
vi.clearAllMocks();
|
|
90
|
-
});
|
|
91
|
-
test('successfully deletes a single schema', async ()=>{
|
|
92
|
-
mockClientWithConfig.delete.mockResolvedValue({
|
|
93
|
-
results: [
|
|
94
|
-
{
|
|
95
|
-
id: '_.schemas.default'
|
|
96
|
-
}
|
|
97
|
-
]
|
|
98
|
-
});
|
|
99
|
-
const result = await deleteSchemaAction({
|
|
100
|
-
'extract-manifest': false,
|
|
101
|
-
ids: '_.schemas.default'
|
|
102
|
-
}, context);
|
|
103
|
-
expect(result).toBe('success');
|
|
104
|
-
expect(mockOutput.log).toHaveBeenCalledWith('Successfully deleted 1/1 schemas');
|
|
105
|
-
expect(mockClientWithConfig.delete).toHaveBeenCalledWith('_.schemas.default');
|
|
106
|
-
expect(mockClientWithConfig.delete).toHaveBeenCalledTimes(2); // Called once per dataset
|
|
107
|
-
});
|
|
108
|
-
test('successfully deletes multiple schemas', async ()=>{
|
|
109
|
-
mockClientWithConfig.delete.mockResolvedValueOnce({
|
|
110
|
-
results: [
|
|
111
|
-
{
|
|
112
|
-
id: '_.schemas.default'
|
|
113
|
-
}
|
|
114
|
-
]
|
|
115
|
-
}).mockResolvedValueOnce({
|
|
116
|
-
results: [
|
|
117
|
-
{
|
|
118
|
-
id: '_.schemas.staging'
|
|
119
|
-
}
|
|
120
|
-
]
|
|
121
|
-
}).mockResolvedValueOnce({
|
|
122
|
-
results: [
|
|
123
|
-
{
|
|
124
|
-
id: '_.schemas.default'
|
|
125
|
-
}
|
|
126
|
-
]
|
|
127
|
-
}).mockResolvedValueOnce({
|
|
128
|
-
results: [
|
|
129
|
-
{
|
|
130
|
-
id: '_.schemas.staging'
|
|
131
|
-
}
|
|
132
|
-
]
|
|
133
|
-
});
|
|
134
|
-
const result = await deleteSchemaAction({
|
|
135
|
-
'extract-manifest': false,
|
|
136
|
-
ids: '_.schemas.default,_.schemas.staging'
|
|
137
|
-
}, context);
|
|
138
|
-
expect(result).toBe('success');
|
|
139
|
-
expect(mockOutput.log).toHaveBeenCalledWith('Successfully deleted 2/2 schemas');
|
|
140
|
-
expect(mockClientWithConfig.delete).toHaveBeenCalledTimes(4); // 2 schemas × 2 datasets
|
|
141
|
-
});
|
|
142
|
-
test('filters schemas by dataset when dataset flag is provided', async ()=>{
|
|
143
|
-
mockClientWithConfig.delete.mockResolvedValue({
|
|
144
|
-
results: [
|
|
145
|
-
{
|
|
146
|
-
id: '_.schemas.default'
|
|
147
|
-
}
|
|
148
|
-
]
|
|
149
|
-
});
|
|
150
|
-
const result = await deleteSchemaAction({
|
|
151
|
-
dataset: 'production',
|
|
152
|
-
'extract-manifest': false,
|
|
153
|
-
ids: '_.schemas.default'
|
|
154
|
-
}, context);
|
|
155
|
-
expect(result).toBe('success');
|
|
156
|
-
expect(mockClientWithConfig.delete).toHaveBeenCalledTimes(1); // Only production dataset
|
|
157
|
-
});
|
|
158
|
-
test('returns failure when schema is not found', async ()=>{
|
|
159
|
-
mockClientWithConfig.delete.mockResolvedValue({
|
|
160
|
-
results: []
|
|
161
|
-
}); // Empty results = not found
|
|
162
|
-
const result = await deleteSchemaAction({
|
|
163
|
-
'extract-manifest': false,
|
|
164
|
-
ids: '_.schemas.nonexistent'
|
|
165
|
-
}, context);
|
|
166
|
-
expect(result).toBe('failure');
|
|
167
|
-
expect(mockOutput.error).toHaveBeenCalled();
|
|
168
|
-
expect(mockOutput.error.mock.calls[0][0]).toContain('Deleted 0/1 schemas');
|
|
169
|
-
expect(mockOutput.error.mock.calls[0][0]).toContain('not found');
|
|
170
|
-
});
|
|
171
|
-
test('returns failure when some schemas are not found', async ()=>{
|
|
172
|
-
mockClientWithConfig.delete.mockResolvedValueOnce({
|
|
173
|
-
results: [
|
|
174
|
-
{
|
|
175
|
-
id: '_.schemas.default'
|
|
176
|
-
}
|
|
177
|
-
]
|
|
178
|
-
}).mockResolvedValueOnce({
|
|
179
|
-
results: []
|
|
180
|
-
}) // Not found
|
|
181
|
-
.mockResolvedValueOnce({
|
|
182
|
-
results: [
|
|
183
|
-
{
|
|
184
|
-
id: '_.schemas.default'
|
|
185
|
-
}
|
|
186
|
-
]
|
|
187
|
-
}).mockResolvedValueOnce({
|
|
188
|
-
results: []
|
|
189
|
-
}); // Not found
|
|
190
|
-
const result = await deleteSchemaAction({
|
|
191
|
-
'extract-manifest': false,
|
|
192
|
-
ids: '_.schemas.default,_.schemas.nonexistent'
|
|
193
|
-
}, context);
|
|
194
|
-
expect(result).toBe('failure');
|
|
195
|
-
expect(mockOutput.error).toHaveBeenCalled();
|
|
196
|
-
expect(mockOutput.error.mock.calls[0][0]).toContain('Deleted 1/2 schemas');
|
|
197
|
-
});
|
|
198
|
-
test('handles delete errors gracefully', async ()=>{
|
|
199
|
-
mockClientWithConfig.delete.mockRejectedValue(new Error('Delete failed'));
|
|
200
|
-
const result = await deleteSchemaAction({
|
|
201
|
-
'extract-manifest': false,
|
|
202
|
-
ids: '_.schemas.default'
|
|
203
|
-
}, context);
|
|
204
|
-
expect(result).toBe('failure');
|
|
205
|
-
expect(mockOutput.error).toHaveBeenCalledWith(expect.stringContaining('Failed to delete schema'));
|
|
206
|
-
});
|
|
207
|
-
test('extracts manifest when extract-manifest is true', async ()=>{
|
|
208
|
-
mockClientWithConfig.delete.mockResolvedValue({
|
|
209
|
-
results: [
|
|
210
|
-
{
|
|
211
|
-
id: '_.schemas.default'
|
|
212
|
-
}
|
|
213
|
-
]
|
|
214
|
-
});
|
|
215
|
-
await deleteSchemaAction({
|
|
216
|
-
'extract-manifest': true,
|
|
217
|
-
ids: '_.schemas.default'
|
|
218
|
-
}, context);
|
|
219
|
-
expect(mockManifestExtractor).toHaveBeenCalled();
|
|
220
|
-
});
|
|
221
|
-
test('skips manifest extraction when extract-manifest is false', async ()=>{
|
|
222
|
-
mockClientWithConfig.delete.mockResolvedValue({
|
|
223
|
-
results: [
|
|
224
|
-
{
|
|
225
|
-
id: '_.schemas.default'
|
|
226
|
-
}
|
|
227
|
-
]
|
|
228
|
-
});
|
|
229
|
-
await deleteSchemaAction({
|
|
230
|
-
'extract-manifest': false,
|
|
231
|
-
ids: '_.schemas.default'
|
|
232
|
-
}, context);
|
|
233
|
-
expect(mockManifestExtractor).not.toHaveBeenCalled();
|
|
234
|
-
});
|
|
235
|
-
test('logs verbose output when verbose flag is enabled', async ()=>{
|
|
236
|
-
mockClientWithConfig.delete.mockRejectedValue(new Error('Delete failed'));
|
|
237
|
-
await deleteSchemaAction({
|
|
238
|
-
'extract-manifest': false,
|
|
239
|
-
ids: '_.schemas.default',
|
|
240
|
-
verbose: true
|
|
241
|
-
}, context);
|
|
242
|
-
// Verbose mode should log the full error object
|
|
243
|
-
expect(mockOutput.error).toHaveBeenCalledWith(expect.any(Error));
|
|
244
|
-
});
|
|
245
|
-
test('throws error when manifest extraction fails with schemaRequired', async ()=>{
|
|
246
|
-
mockManifestExtractor.mockRejectedValue(new Error('Manifest extraction failed'));
|
|
247
|
-
await expect(deleteSchemaAction({
|
|
248
|
-
'extract-manifest': true,
|
|
249
|
-
ids: '_.schemas.default'
|
|
250
|
-
}, context)).rejects.toThrow('Manifest extraction failed');
|
|
251
|
-
});
|
|
252
|
-
test('filters workspaces by projectId mismatch', async ()=>{
|
|
253
|
-
const mismatchManifest = {
|
|
254
|
-
...mockManifest,
|
|
255
|
-
workspaces: [
|
|
256
|
-
{
|
|
257
|
-
...mockManifest.workspaces[0],
|
|
258
|
-
projectId: 'test-project'
|
|
259
|
-
},
|
|
260
|
-
{
|
|
261
|
-
...mockManifest.workspaces[1],
|
|
262
|
-
projectId: 'different-project'
|
|
263
|
-
}
|
|
264
|
-
]
|
|
265
|
-
};
|
|
266
|
-
mockJsonReader.mockImplementation(async (filePath)=>{
|
|
267
|
-
if (filePath.includes('create-manifest.json')) {
|
|
268
|
-
return {
|
|
269
|
-
lastModified: '2024-01-01T00:00:00.000Z',
|
|
270
|
-
parsedJson: mismatchManifest,
|
|
271
|
-
path: filePath
|
|
272
|
-
};
|
|
273
|
-
}
|
|
274
|
-
return undefined;
|
|
275
|
-
});
|
|
276
|
-
mockClientWithConfig.delete.mockResolvedValue({
|
|
277
|
-
results: [
|
|
278
|
-
{
|
|
279
|
-
id: '_.schemas.default'
|
|
280
|
-
}
|
|
281
|
-
]
|
|
282
|
-
});
|
|
283
|
-
await deleteSchemaAction({
|
|
284
|
-
'extract-manifest': false,
|
|
285
|
-
ids: '_.schemas.default'
|
|
286
|
-
}, context);
|
|
287
|
-
// Should warn about project ID mismatch
|
|
288
|
-
expect(mockOutput.warn).toHaveBeenCalled();
|
|
289
|
-
// Should only delete from matching project
|
|
290
|
-
expect(mockClientWithConfig.delete).toHaveBeenCalledTimes(1);
|
|
291
|
-
});
|
|
292
|
-
});
|
|
293
|
-
|
|
294
|
-
//# sourceMappingURL=deleteSchemaAction.test.js.map
|