@payloadcms/db-d1-sqlite 0.0.1-beta.0 → 3.58.0-internal.8775d75
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/README.md +29 -2
- package/dist/connect.d.ts +3 -0
- package/dist/connect.d.ts.map +1 -0
- package/dist/connect.js +53 -0
- package/dist/connect.js.map +1 -0
- package/dist/drizzle-proxy/d1.d.ts +2 -0
- package/dist/drizzle-proxy/d1.d.ts.map +1 -0
- package/dist/drizzle-proxy/d1.js +3 -0
- package/dist/drizzle-proxy/d1.js.map +1 -0
- package/dist/drizzle-proxy/index.d.ts +2 -0
- package/dist/drizzle-proxy/index.d.ts.map +1 -0
- package/dist/drizzle-proxy/index.js +3 -0
- package/dist/drizzle-proxy/index.js.map +1 -0
- package/dist/drizzle-proxy/relations.d.ts +2 -0
- package/dist/drizzle-proxy/relations.d.ts.map +1 -0
- package/dist/drizzle-proxy/relations.js +3 -0
- package/dist/drizzle-proxy/relations.js.map +1 -0
- package/dist/drizzle-proxy/sqlite-core.d.ts +2 -0
- package/dist/drizzle-proxy/sqlite-core.d.ts.map +1 -0
- package/dist/drizzle-proxy/sqlite-core.js +3 -0
- package/dist/drizzle-proxy/sqlite-core.js.map +1 -0
- package/dist/execute.d.ts +3 -0
- package/dist/execute.d.ts.map +1 -0
- package/dist/execute.js +28 -0
- package/dist/execute.js.map +1 -0
- package/dist/exports/types-deprecated.d.ts +62 -0
- package/dist/exports/types-deprecated.d.ts.map +1 -0
- package/dist/exports/types-deprecated.js +5 -0
- package/dist/exports/types-deprecated.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +140 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +162 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +88 -1
- package/.prettierignore +0 -12
- package/.swcrc +0 -24
- package/eslint.config.js +0 -18
- package/src/addresses/addressesCollection.ts +0 -76
- package/src/addresses/defaultAddressFields.ts +0 -83
- package/src/addresses/defaultCountries.ts +0 -50
- package/src/carts/beforeChange.ts +0 -51
- package/src/carts/cartsCollection.ts +0 -146
- package/src/currencies/index.ts +0 -29
- package/src/endpoints/confirmOrder.ts +0 -312
- package/src/endpoints/initiatePayment.ts +0 -322
- package/src/exports/addresses.ts +0 -2
- package/src/exports/currencies.ts +0 -1
- package/src/exports/fields.ts +0 -5
- package/src/exports/orders.ts +0 -1
- package/src/exports/payments/stripe.ts +0 -1
- package/src/exports/plugin.ts +0 -1
- package/src/exports/products.ts +0 -1
- package/src/exports/react.ts +0 -8
- package/src/exports/transactions.ts +0 -1
- package/src/exports/translations.ts +0 -1
- package/src/exports/types.ts +0 -7
- package/src/exports/ui.ts +0 -3
- package/src/exports/variants.ts +0 -5
- package/src/fields/amountField.ts +0 -43
- package/src/fields/cartItemsField.ts +0 -84
- package/src/fields/currencyField.ts +0 -39
- package/src/fields/inventoryField.ts +0 -22
- package/src/fields/pricesField.ts +0 -65
- package/src/fields/statusField.ts +0 -57
- package/src/fields/variantsFields.ts +0 -56
- package/src/index.ts +0 -275
- package/src/orders/ordersCollection.ts +0 -157
- package/src/payments/adapters/stripe/confirmOrder.ts +0 -123
- package/src/payments/adapters/stripe/endpoints/webhooks.ts +0 -69
- package/src/payments/adapters/stripe/index.ts +0 -135
- package/src/payments/adapters/stripe/initiatePayment.ts +0 -131
- package/src/products/productsCollection.ts +0 -78
- package/src/react/provider/index.tsx +0 -893
- package/src/react/provider/types.ts +0 -184
- package/src/react/provider/utilities.ts +0 -22
- package/src/transactions/transactionsCollection.ts +0 -166
- package/src/translations/en.ts +0 -64
- package/src/translations/index.ts +0 -11
- package/src/translations/translation-schema.json +0 -35
- package/src/types.ts +0 -403
- package/src/ui/PriceInput/FormattedInput.tsx +0 -134
- package/src/ui/PriceInput/index.scss +0 -28
- package/src/ui/PriceInput/index.tsx +0 -43
- package/src/ui/PriceInput/utilities.ts +0 -46
- package/src/ui/PriceRowLabel/index.css +0 -13
- package/src/ui/PriceRowLabel/index.tsx +0 -56
- package/src/ui/VariantOptionsSelector/ErrorBox.tsx +0 -27
- package/src/ui/VariantOptionsSelector/OptionsSelect.tsx +0 -78
- package/src/ui/VariantOptionsSelector/index.css +0 -37
- package/src/ui/VariantOptionsSelector/index.tsx +0 -83
- package/src/utilities/defaultProductsValidation.ts +0 -42
- package/src/utilities/errorCodes.ts +0 -14
- package/src/utilities/getCollectionSlugMap.ts +0 -84
- package/src/utilities/sanitizePluginConfig.ts +0 -80
- package/src/variants/variantOptionsCollection.ts +0 -59
- package/src/variants/variantTypesCollection.ts +0 -55
- package/src/variants/variantsCollection/hooks/beforeChange.ts +0 -47
- package/src/variants/variantsCollection/hooks/validateOptions.ts +0 -72
- package/src/variants/variantsCollection/index.ts +0 -119
- package/tsconfig.json +0 -7
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,KAAK,EAAE,qBAAqB,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AACpG,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AACnF,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AAC1E,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AACtE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACxD,OAAO,KAAK,EACV,eAAe,EACf,oCAAoC,EACpC,sBAAsB,EACtB,uBAAuB,EACxB,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EAAE,SAA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AM,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAA;QAC/B,cAAc,CAAC,EAAE;YACf,IAAI,EAAE,CAAC,IAAI,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;YAC9C,IAAI,EAAE,MAAM,CAAA;YACZ,EAAE,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;SAC3C,EAAE,CAAA;QACH,IAAI,EAAE,OAAO,CAAA;QACb,kBAAkB,EAAE,MAAM,IAAI,CAAA;QAC9B,mBAAmB,CAAC,EAAE,MAAM,CAAA;QAC5B,mBAAmB,EAAE,MAAM,IAAI,CAAA;QAC/B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,GAAG,YAAY,CAAC,CAAA;QACtD,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;QACjC,kBAAkB,EAAE,uBAAuB,CAAA;QAC3C,cAAc,CAAC,EAAE,MAAM,CAAA;KACxB;CACF"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { ResultSet } from '@libsql/client'\nimport type { BuildQueryJoinAliases, DrizzleAdapter, extendDrizzleTable } from '@payloadcms/drizzle'\nimport type { BaseSQLiteAdapter, BaseSQLiteArgs } from '@payloadcms/drizzle/sqlite'\nimport type { DrizzleConfig, Relation, Relations, SQL } from 'drizzle-orm'\nimport type { AnyD1Database, DrizzleD1Database } from 'drizzle-orm/d1'\nimport type { LibSQLDatabase } from 'drizzle-orm/libsql'\nimport type {\n AnySQLiteColumn,\n SQLiteInsertOnConflictDoUpdateConfig,\n SQLiteTableWithColumns,\n SQLiteTransactionConfig,\n} from 'drizzle-orm/sqlite-core'\nimport type { SQLiteRaw } from 'drizzle-orm/sqlite-core/query-builders/raw'\nimport type { Payload, PayloadRequest } from 'payload'\n\ntype SQLiteSchema = {\n relations: Record<string, GenericRelation>\n tables: Record<string, SQLiteTableWithColumns<any>>\n}\n\ntype SQLiteSchemaHookArgs = {\n extendTable: typeof extendDrizzleTable\n schema: SQLiteSchema\n}\n\nexport type SQLiteSchemaHook = (args: SQLiteSchemaHookArgs) => Promise<SQLiteSchema> | SQLiteSchema\n\nexport type Args = {\n binding: AnyD1Database\n} & BaseSQLiteArgs\n\nexport type GenericColumns = {\n [x: string]: AnySQLiteColumn\n}\n\nexport type GenericTable = SQLiteTableWithColumns<{\n columns: GenericColumns\n dialect: string\n name: string\n schema: string\n}>\n\nexport type GenericRelation = Relations<string, Record<string, Relation<string>>>\n\nexport type CountDistinct = (args: {\n db: LibSQLDatabase\n joins: BuildQueryJoinAliases\n tableName: string\n where: SQL\n}) => Promise<number>\n\nexport type DeleteWhere = (args: {\n db: LibSQLDatabase\n tableName: string\n where: SQL\n}) => Promise<void>\n\nexport type DropDatabase = (args: { adapter: SQLiteD1Adapter }) => Promise<void>\n\nexport type Execute<T> = (args: {\n db?: LibSQLDatabase\n drizzle?: LibSQLDatabase\n raw?: string\n sql?: SQL<unknown>\n}) => SQLiteRaw<Promise<T>> | SQLiteRaw<ResultSet>\n\nexport type Insert = (args: {\n db: LibSQLDatabase\n onConflictDoUpdate?: SQLiteInsertOnConflictDoUpdateConfig<any>\n tableName: string\n values: Record<string, unknown> | Record<string, unknown>[]\n}) => Promise<Record<string, unknown>[]>\n\n// Explicitly omit drizzle property for complete override in SQLiteAdapter, required in ts 5.5\ntype SQLiteDrizzleAdapter = Omit<\n DrizzleAdapter,\n | 'countDistinct'\n | 'deleteWhere'\n | 'drizzle'\n | 'dropDatabase'\n | 'execute'\n | 'idType'\n | 'insert'\n | 'operators'\n | 'relations'\n>\n\nexport interface GeneratedDatabaseSchema {\n schemaUntyped: Record<string, unknown>\n}\n\ntype ResolveSchemaType<T> = 'schema' extends keyof T\n ? T['schema']\n : GeneratedDatabaseSchema['schemaUntyped']\n\ntype Drizzle = { $client: AnyD1Database } & DrizzleD1Database<Record<string, any>>\n\nexport type SQLiteD1Adapter = {\n binding: Args['binding']\n client: AnyD1Database\n drizzle: Drizzle\n} & BaseSQLiteAdapter &\n SQLiteDrizzleAdapter\n\nexport type IDType = 'integer' | 'numeric' | 'text'\n\nexport type MigrateUpArgs = {\n /**\n * The SQLite Drizzle instance that you can use to execute SQL directly within the current transaction.\n * @example\n * ```ts\n * import { type MigrateUpArgs, sql } from '@payloadcms/db-sqlite'\n *\n * export async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {\n * const { rows: posts } = await db.run(sql`SELECT * FROM posts`)\n * }\n * ```\n */\n db: Drizzle\n /**\n * The Payload instance that you can use to execute Local API methods\n * To use the current transaction you must pass `req` to arguments\n * @example\n * ```ts\n * import { type MigrateUpArgs } from '@payloadcms/db-sqlite'\n *\n * export async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {\n * const posts = await payload.find({ collection: 'posts', req })\n * }\n * ```\n */\n payload: Payload\n /**\n * The `PayloadRequest` object that contains the current transaction\n */\n req: PayloadRequest\n}\nexport type MigrateDownArgs = {\n /**\n * The SQLite Drizzle instance that you can use to execute SQL directly within the current transaction.\n * @example\n * ```ts\n * import { type MigrateDownArgs, sql } from '@payloadcms/db-sqlite'\n *\n * export async function down({ db, payload, req }: MigrateDownArgs): Promise<void> {\n * const { rows: posts } = await db.run(sql`SELECT * FROM posts`)\n * }\n * ```\n */\n db: Drizzle\n /**\n * The Payload instance that you can use to execute Local API methods\n * To use the current transaction you must pass `req` to arguments\n * @example\n * ```ts\n * import { type MigrateDownArgs } from '@payloadcms/db-sqlite'\n *\n * export async function down({ db, payload, req }: MigrateDownArgs): Promise<void> {\n * const posts = await payload.find({ collection: 'posts', req })\n * }\n * ```\n */\n payload: Payload\n /**\n * The `PayloadRequest` object that contains the current transaction\n */\n req: PayloadRequest\n}\n\ndeclare module 'payload' {\n export interface DatabaseAdapter\n extends Omit<Args, 'idType' | 'logger' | 'migrationDir' | 'pool'>,\n DrizzleAdapter {\n beginTransaction: (options?: SQLiteTransactionConfig) => Promise<null | number | string>\n drizzle: Drizzle\n /**\n * An object keyed on each table, with a key value pair where the constraint name is the key, followed by the dot-notation field name\n * Used for returning properly formed errors from unique fields\n */\n fieldConstraints: Record<string, Record<string, string>>\n idType: Args['idType']\n initializing: Promise<void>\n localesSuffix?: string\n logger: DrizzleConfig['logger']\n prodMigrations?: {\n down: (args: MigrateDownArgs) => Promise<void>\n name: string\n up: (args: MigrateUpArgs) => Promise<void>\n }[]\n push: boolean\n rejectInitializing: () => void\n relationshipsSuffix?: string\n resolveInitializing: () => void\n schema: Record<string, GenericRelation | GenericTable>\n tableNameMap: Map<string, string>\n transactionOptions: SQLiteTransactionConfig\n versionsSuffix?: string\n }\n}\n"],"names":[],"mappings":"AAyIA,WA8BC"}
|
package/package.json
CHANGED
|
@@ -1,4 +1,91 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/db-d1-sqlite",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.58.0-internal.8775d75",
|
|
4
|
+
"description": "The officially supported D1 SQLite database adapter for Payload",
|
|
5
|
+
"homepage": "https://payloadcms.com",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/payloadcms/payload.git",
|
|
9
|
+
"directory": "packages/db-d1-sqlite"
|
|
10
|
+
},
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"author": "Payload <dev@payloadcms.com> (https://payloadcms.com)",
|
|
13
|
+
"maintainers": [
|
|
14
|
+
{
|
|
15
|
+
"name": "Payload",
|
|
16
|
+
"email": "info@payloadcms.com",
|
|
17
|
+
"url": "https://payloadcms.com"
|
|
18
|
+
}
|
|
19
|
+
],
|
|
20
|
+
"type": "module",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"import": "./dist/index.js",
|
|
24
|
+
"require": "./dist/index.js",
|
|
25
|
+
"types": "./dist/index.d.ts"
|
|
26
|
+
},
|
|
27
|
+
"./types": {
|
|
28
|
+
"import": "./dist/exports/types-deprecated.js",
|
|
29
|
+
"require": "./dist/exports/types-deprecated.js",
|
|
30
|
+
"types": "./dist/exports/types-deprecated.d.ts"
|
|
31
|
+
},
|
|
32
|
+
"./migration-utils": {
|
|
33
|
+
"import": "./dist/exports/migration-utils.js",
|
|
34
|
+
"require": "./dist/exports/migration-utils.js",
|
|
35
|
+
"types": "./dist/exports/migration-utils.d.ts"
|
|
36
|
+
},
|
|
37
|
+
"./drizzle": {
|
|
38
|
+
"import": "./dist/drizzle-proxy/index.js",
|
|
39
|
+
"types": "./dist/drizzle-proxy/index.d.ts",
|
|
40
|
+
"default": "./dist/drizzle-proxy/index.js"
|
|
41
|
+
},
|
|
42
|
+
"./drizzle/sqlite-core": {
|
|
43
|
+
"import": "./dist/drizzle-proxy/sqlite-core.js",
|
|
44
|
+
"types": "./dist/drizzle-proxy/sqlite-core.d.ts",
|
|
45
|
+
"default": "./dist/drizzle-proxy/sqlite-core.js"
|
|
46
|
+
},
|
|
47
|
+
"./drizzle/d1": {
|
|
48
|
+
"import": "./dist/drizzle-proxy/d1.js",
|
|
49
|
+
"types": "./dist/drizzle-proxy/d1.d.ts",
|
|
50
|
+
"default": "./dist/drizzle-proxy/d1.js"
|
|
51
|
+
},
|
|
52
|
+
"./drizzle/relations": {
|
|
53
|
+
"import": "./dist/drizzle-proxy/relations.js",
|
|
54
|
+
"types": "./dist/drizzle-proxy/relations.d.ts",
|
|
55
|
+
"default": "./dist/drizzle-proxy/relations.js"
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"main": "./dist/index.js",
|
|
59
|
+
"types": "./dist/index.d.ts",
|
|
60
|
+
"files": [
|
|
61
|
+
"dist",
|
|
62
|
+
"mock.js"
|
|
63
|
+
],
|
|
64
|
+
"dependencies": {
|
|
65
|
+
"console-table-printer": "2.12.1",
|
|
66
|
+
"drizzle-kit": "0.31.4",
|
|
67
|
+
"drizzle-orm": "0.44.2",
|
|
68
|
+
"prompts": "2.4.2",
|
|
69
|
+
"to-snake-case": "1.0.0",
|
|
70
|
+
"uuid": "9.0.0",
|
|
71
|
+
"@payloadcms/drizzle": "3.58.0-internal.8775d75"
|
|
72
|
+
},
|
|
73
|
+
"devDependencies": {
|
|
74
|
+
"@types/pg": "8.10.2",
|
|
75
|
+
"@types/to-snake-case": "1.0.0",
|
|
76
|
+
"@types/uuid": "10.0.0",
|
|
77
|
+
"@payloadcms/eslint-config": "3.28.0",
|
|
78
|
+
"payload": "3.58.0-internal.8775d75"
|
|
79
|
+
},
|
|
80
|
+
"peerDependencies": {
|
|
81
|
+
"payload": "3.58.0-internal.8775d75"
|
|
82
|
+
},
|
|
83
|
+
"scripts": {
|
|
84
|
+
"build": "pnpm build:swc && pnpm build:types",
|
|
85
|
+
"build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
|
|
86
|
+
"build:types": "tsc --emitDeclarationOnly --outDir dist",
|
|
87
|
+
"clean": "rimraf -g {dist,*.tsbuildinfo}",
|
|
88
|
+
"lint": "eslint .",
|
|
89
|
+
"lint:fix": "eslint . --fix"
|
|
90
|
+
}
|
|
4
91
|
}
|
package/.prettierignore
DELETED
package/.swcrc
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://json.schemastore.org/swcrc",
|
|
3
|
-
"sourceMaps": true,
|
|
4
|
-
"jsc": {
|
|
5
|
-
"target": "esnext",
|
|
6
|
-
"parser": {
|
|
7
|
-
"syntax": "typescript",
|
|
8
|
-
"tsx": true,
|
|
9
|
-
"dts": true
|
|
10
|
-
},
|
|
11
|
-
"transform": {
|
|
12
|
-
"react": {
|
|
13
|
-
"runtime": "automatic",
|
|
14
|
-
"pragmaFrag": "React.Fragment",
|
|
15
|
-
"throwIfNamespace": true,
|
|
16
|
-
"development": false,
|
|
17
|
-
"useBuiltins": true
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
"module": {
|
|
22
|
-
"type": "es6"
|
|
23
|
-
}
|
|
24
|
-
}
|
package/eslint.config.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { rootEslintConfig, rootParserOptions } from '../../eslint.config.js'
|
|
2
|
-
|
|
3
|
-
/** @typedef {import('eslint').Linter.Config} Config */
|
|
4
|
-
|
|
5
|
-
/** @type {Config[]} */
|
|
6
|
-
export const index = [
|
|
7
|
-
...rootEslintConfig,
|
|
8
|
-
{
|
|
9
|
-
languageOptions: {
|
|
10
|
-
parserOptions: {
|
|
11
|
-
...rootParserOptions,
|
|
12
|
-
tsconfigRootDir: import.meta.dirname,
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
]
|
|
17
|
-
|
|
18
|
-
export default index
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import type { CollectionConfig, Field } from 'payload'
|
|
2
|
-
|
|
3
|
-
import type { CountryType, FieldsOverride } from '../types.js'
|
|
4
|
-
|
|
5
|
-
import { defaultCountries } from './defaultCountries.js'
|
|
6
|
-
|
|
7
|
-
type Props = {
|
|
8
|
-
/**
|
|
9
|
-
* Array of fields used for capturing the address data. Use this over overrides to customise the fields here as it's reused across the plugin.
|
|
10
|
-
*/
|
|
11
|
-
addressFields: Field[]
|
|
12
|
-
/**
|
|
13
|
-
* Slug of the customers collection, defaults to 'users'.
|
|
14
|
-
*/
|
|
15
|
-
customersSlug?: string
|
|
16
|
-
overrides?: { fields?: FieldsOverride } & Partial<Omit<CollectionConfig, 'fields'>>
|
|
17
|
-
supportedCountries?: CountryType[]
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export const addressesCollection: (props: Props) => CollectionConfig = (props) => {
|
|
21
|
-
const { addressFields, customersSlug = 'users', overrides } = props || {}
|
|
22
|
-
const fieldsOverride = overrides?.fields
|
|
23
|
-
|
|
24
|
-
const { supportedCountries: supportedCountriesFromProps } = props || {}
|
|
25
|
-
const supportedCountries = supportedCountriesFromProps || defaultCountries
|
|
26
|
-
const hasOnlyOneCountry = supportedCountries && supportedCountries.length === 1
|
|
27
|
-
|
|
28
|
-
const defaultFields: Field[] = [
|
|
29
|
-
{
|
|
30
|
-
name: 'customer',
|
|
31
|
-
type: 'relationship',
|
|
32
|
-
label: ({ t }) =>
|
|
33
|
-
// @ts-expect-error - translations are not typed in plugins yet
|
|
34
|
-
t('plugin-ecommerce:customer'),
|
|
35
|
-
relationTo: customersSlug,
|
|
36
|
-
},
|
|
37
|
-
...addressFields.map((field) => {
|
|
38
|
-
if ('name' in field && field.name === 'country') {
|
|
39
|
-
return {
|
|
40
|
-
name: 'country',
|
|
41
|
-
type: 'select',
|
|
42
|
-
label: ({ t }) =>
|
|
43
|
-
// @ts-expect-error - translations are not typed in plugins yet
|
|
44
|
-
t('plugin-ecommerce:addressCountry'),
|
|
45
|
-
options: supportedCountries || defaultCountries,
|
|
46
|
-
required: true,
|
|
47
|
-
...(supportedCountries && supportedCountries?.[0] && hasOnlyOneCountry
|
|
48
|
-
? {
|
|
49
|
-
defaultValue: supportedCountries?.[0].value,
|
|
50
|
-
}
|
|
51
|
-
: {}),
|
|
52
|
-
} as Field
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return field
|
|
56
|
-
}),
|
|
57
|
-
]
|
|
58
|
-
|
|
59
|
-
const fields =
|
|
60
|
-
fieldsOverride && typeof fieldsOverride === 'function'
|
|
61
|
-
? fieldsOverride({ defaultFields })
|
|
62
|
-
: defaultFields
|
|
63
|
-
|
|
64
|
-
const baseConfig: CollectionConfig = {
|
|
65
|
-
slug: 'addresses',
|
|
66
|
-
timestamps: true,
|
|
67
|
-
...overrides,
|
|
68
|
-
admin: {
|
|
69
|
-
useAsTitle: 'createdAt',
|
|
70
|
-
...overrides?.admin,
|
|
71
|
-
},
|
|
72
|
-
fields,
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return { ...baseConfig }
|
|
76
|
-
}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import type { Field } from 'payload'
|
|
2
|
-
|
|
3
|
-
export const defaultAddressFields: () => Field[] = () => {
|
|
4
|
-
return [
|
|
5
|
-
{
|
|
6
|
-
name: 'title',
|
|
7
|
-
type: 'text',
|
|
8
|
-
label: ({ t }) =>
|
|
9
|
-
// @ts-expect-error - translations are not typed in plugins yet
|
|
10
|
-
t('plugin-ecommerce:addressTitle'),
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
name: 'firstName',
|
|
14
|
-
type: 'text',
|
|
15
|
-
label: ({ t }) =>
|
|
16
|
-
// @ts-expect-error - translations are not typed in plugins yet
|
|
17
|
-
t('plugin-ecommerce:addressFirstName'),
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
name: 'lastName',
|
|
21
|
-
type: 'text',
|
|
22
|
-
label: ({ t }) =>
|
|
23
|
-
// @ts-expect-error - translations are not typed in plugins yet
|
|
24
|
-
t('plugin-ecommerce:addressLastName'),
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
name: 'company',
|
|
28
|
-
type: 'text',
|
|
29
|
-
label: ({ t }) =>
|
|
30
|
-
// @ts-expect-error - translations are not typed in plugins yet
|
|
31
|
-
t('plugin-ecommerce:addressCompany'),
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
name: 'addressLine1',
|
|
35
|
-
type: 'text',
|
|
36
|
-
label: ({ t }) =>
|
|
37
|
-
// @ts-expect-error - translations are not typed in plugins yet
|
|
38
|
-
t('plugin-ecommerce:addressLine1'),
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
name: 'addressLine2',
|
|
42
|
-
type: 'text',
|
|
43
|
-
label: ({ t }) =>
|
|
44
|
-
// @ts-expect-error - translations are not typed in plugins yet
|
|
45
|
-
t('plugin-ecommerce:addressLine2'),
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
name: 'city',
|
|
49
|
-
type: 'text',
|
|
50
|
-
label: ({ t }) =>
|
|
51
|
-
// @ts-expect-error - translations are not typed in plugins yet
|
|
52
|
-
t('plugin-ecommerce:addressCity'),
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
name: 'state',
|
|
56
|
-
type: 'text',
|
|
57
|
-
label: ({ t }) =>
|
|
58
|
-
// @ts-expect-error - translations are not typed in plugins yet
|
|
59
|
-
t('plugin-ecommerce:addressState'),
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
name: 'postalCode',
|
|
63
|
-
type: 'text',
|
|
64
|
-
label: ({ t }) =>
|
|
65
|
-
// @ts-expect-error - translations are not typed in plugins yet
|
|
66
|
-
t('plugin-ecommerce:addressPostalCode'),
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
name: 'country',
|
|
70
|
-
type: 'text',
|
|
71
|
-
label: ({ t }) =>
|
|
72
|
-
// @ts-expect-error - translations are not typed in plugins yet
|
|
73
|
-
t('plugin-ecommerce:addressCountry'),
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
name: 'phone',
|
|
77
|
-
type: 'text',
|
|
78
|
-
label: ({ t }) =>
|
|
79
|
-
// @ts-expect-error - translations are not typed in plugins yet
|
|
80
|
-
t('plugin-ecommerce:addressPhone'),
|
|
81
|
-
},
|
|
82
|
-
]
|
|
83
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import type { CountryType } from '../types.js'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Default list of countries supported for forms and payments.
|
|
5
|
-
* This can be overriden or reused in other parts of the application.
|
|
6
|
-
*
|
|
7
|
-
* The label is the human-readable name of the country, and the value is the ISO 3166-1 alpha-2 code.
|
|
8
|
-
*/
|
|
9
|
-
export const defaultCountries: CountryType[] = [
|
|
10
|
-
{ label: 'United States', value: 'US' },
|
|
11
|
-
{ label: 'United Kingdom', value: 'GB' },
|
|
12
|
-
{ label: 'Canada', value: 'CA' },
|
|
13
|
-
{ label: 'Australia', value: 'AU' },
|
|
14
|
-
{ label: 'Austria', value: 'AT' },
|
|
15
|
-
{ label: 'Belgium', value: 'BE' },
|
|
16
|
-
{ label: 'Brazil', value: 'BR' },
|
|
17
|
-
{ label: 'Bulgaria', value: 'BG' },
|
|
18
|
-
{ label: 'Cyprus', value: 'CY' },
|
|
19
|
-
{ label: 'Czech Republic', value: 'CZ' },
|
|
20
|
-
{ label: 'Denmark', value: 'DK' },
|
|
21
|
-
{ label: 'Estonia', value: 'EE' },
|
|
22
|
-
{ label: 'Finland', value: 'FI' },
|
|
23
|
-
{ label: 'France', value: 'FR' },
|
|
24
|
-
{ label: 'Germany', value: 'DE' },
|
|
25
|
-
{ label: 'Greece', value: 'GR' },
|
|
26
|
-
{ label: 'Hong Kong', value: 'HK' },
|
|
27
|
-
{ label: 'Hungary', value: 'HU' },
|
|
28
|
-
{ label: 'India', value: 'IN' },
|
|
29
|
-
{ label: 'Ireland', value: 'IE' },
|
|
30
|
-
{ label: 'Italy', value: 'IT' },
|
|
31
|
-
{ label: 'Japan', value: 'JP' },
|
|
32
|
-
{ label: 'Latvia', value: 'LV' },
|
|
33
|
-
{ label: 'Lithuania', value: 'LT' },
|
|
34
|
-
{ label: 'Luxembourg', value: 'LU' },
|
|
35
|
-
{ label: 'Malaysia', value: 'MY' },
|
|
36
|
-
{ label: 'Malta', value: 'MT' },
|
|
37
|
-
{ label: 'Mexico', value: 'MX' },
|
|
38
|
-
{ label: 'Netherlands', value: 'NL' },
|
|
39
|
-
{ label: 'New Zealand', value: 'NZ' },
|
|
40
|
-
{ label: 'Norway', value: 'NO' },
|
|
41
|
-
{ label: 'Poland', value: 'PL' },
|
|
42
|
-
{ label: 'Portugal', value: 'PT' },
|
|
43
|
-
{ label: 'Romania', value: 'RO' },
|
|
44
|
-
{ label: 'Singapore', value: 'SG' },
|
|
45
|
-
{ label: 'Slovakia', value: 'SK' },
|
|
46
|
-
{ label: 'Slovenia', value: 'SI' },
|
|
47
|
-
{ label: 'Spain', value: 'ES' },
|
|
48
|
-
{ label: 'Sweden', value: 'SE' },
|
|
49
|
-
{ label: 'Switzerland', value: 'CH' },
|
|
50
|
-
]
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import type { CollectionBeforeChangeHook } from 'payload'
|
|
2
|
-
|
|
3
|
-
type Props = {
|
|
4
|
-
productsSlug: string
|
|
5
|
-
variantsSlug: string
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export const beforeChangeCart: (args: Props) => CollectionBeforeChangeHook =
|
|
9
|
-
({ productsSlug, variantsSlug }) =>
|
|
10
|
-
async ({ data, req }) => {
|
|
11
|
-
// Update subtotal based on items in the cart
|
|
12
|
-
if (data.items && Array.isArray(data.items)) {
|
|
13
|
-
const priceField = `priceIn${data.currency}`
|
|
14
|
-
|
|
15
|
-
let subtotal = 0
|
|
16
|
-
|
|
17
|
-
for (const item of data.items) {
|
|
18
|
-
if (item.variant) {
|
|
19
|
-
const id = typeof item.variant === 'object' ? item.variant.id : item.variant
|
|
20
|
-
|
|
21
|
-
const variant = await req.payload.findByID({
|
|
22
|
-
id,
|
|
23
|
-
collection: variantsSlug,
|
|
24
|
-
depth: 0,
|
|
25
|
-
select: {
|
|
26
|
-
[priceField]: true,
|
|
27
|
-
},
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
subtotal += variant[priceField] * item.quantity
|
|
31
|
-
} else {
|
|
32
|
-
const id = typeof item.product === 'object' ? item.product.id : item.product
|
|
33
|
-
|
|
34
|
-
const product = await req.payload.findByID({
|
|
35
|
-
id,
|
|
36
|
-
collection: productsSlug,
|
|
37
|
-
depth: 0,
|
|
38
|
-
select: {
|
|
39
|
-
[priceField]: true,
|
|
40
|
-
},
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
subtotal += product[priceField] * item.quantity
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
data.subtotal = subtotal
|
|
48
|
-
} else {
|
|
49
|
-
data.subtotal = 0
|
|
50
|
-
}
|
|
51
|
-
}
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import type { CollectionConfig, Field } from 'payload'
|
|
2
|
-
|
|
3
|
-
import type { CurrenciesConfig, FieldsOverride } from '../types.js'
|
|
4
|
-
|
|
5
|
-
import { amountField } from '../fields/amountField.js'
|
|
6
|
-
import { cartItemsField } from '../fields/cartItemsField.js'
|
|
7
|
-
import { currencyField } from '../fields/currencyField.js'
|
|
8
|
-
import { beforeChangeCart } from './beforeChange.js'
|
|
9
|
-
|
|
10
|
-
type Props = {
|
|
11
|
-
currenciesConfig?: CurrenciesConfig
|
|
12
|
-
/**
|
|
13
|
-
* Slug of the customers collection, defaults to 'users'.
|
|
14
|
-
*/
|
|
15
|
-
customersSlug?: string
|
|
16
|
-
/**
|
|
17
|
-
* Enables support for variants in the cart.
|
|
18
|
-
* Defaults to false.
|
|
19
|
-
*/
|
|
20
|
-
enableVariants?: boolean
|
|
21
|
-
overrides?: { fields?: FieldsOverride } & Partial<Omit<CollectionConfig, 'fields'>>
|
|
22
|
-
/**
|
|
23
|
-
* Slug of the products collection, defaults to 'products'.
|
|
24
|
-
*/
|
|
25
|
-
productsSlug?: string
|
|
26
|
-
/**
|
|
27
|
-
* Slug of the variants collection, defaults to 'variants'.
|
|
28
|
-
*/
|
|
29
|
-
variantsSlug?: string
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export const cartsCollection: (props?: Props) => CollectionConfig = (props) => {
|
|
33
|
-
const {
|
|
34
|
-
currenciesConfig,
|
|
35
|
-
customersSlug = 'users',
|
|
36
|
-
enableVariants = false,
|
|
37
|
-
overrides,
|
|
38
|
-
productsSlug = 'products',
|
|
39
|
-
variantsSlug = 'variants',
|
|
40
|
-
} = props || {}
|
|
41
|
-
const fieldsOverride = overrides?.fields
|
|
42
|
-
|
|
43
|
-
const defaultFields: Field[] = [
|
|
44
|
-
{
|
|
45
|
-
name: 'customer',
|
|
46
|
-
type: 'relationship',
|
|
47
|
-
label: ({ t }) =>
|
|
48
|
-
// @ts-expect-error - translations are not typed in plugins yet
|
|
49
|
-
t('plugin-ecommerce:customer'),
|
|
50
|
-
relationTo: customersSlug,
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
name: 'purchasedAt',
|
|
54
|
-
type: 'date',
|
|
55
|
-
label: ({ t }) =>
|
|
56
|
-
// @ts-expect-error - translations are not typed in plugins yet
|
|
57
|
-
t('plugin-ecommerce:purchasedAt'),
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
name: 'status',
|
|
61
|
-
type: 'select',
|
|
62
|
-
defaultValue: 'open',
|
|
63
|
-
interfaceName: 'CartStatus',
|
|
64
|
-
label: ({ t }) =>
|
|
65
|
-
// @ts-expect-error - translations are not typed in plugins yet
|
|
66
|
-
t('plugin-ecommerce:status'),
|
|
67
|
-
options: [
|
|
68
|
-
{
|
|
69
|
-
// @ts-expect-error - translations are not typed in plugins yet
|
|
70
|
-
label: ({ t }) => t('plugin-ecommerce:open'),
|
|
71
|
-
value: 'open',
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
// @ts-expect-error - translations are not typed in plugins yet
|
|
75
|
-
label: ({ t }) => t('plugin-ecommerce:abandoned'),
|
|
76
|
-
value: 'abandoned',
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
// @ts-expect-error - translations are not typed in plugins yet
|
|
80
|
-
label: ({ t }) => t('plugin-ecommerce:completed'),
|
|
81
|
-
value: 'completed',
|
|
82
|
-
},
|
|
83
|
-
],
|
|
84
|
-
},
|
|
85
|
-
...(currenciesConfig
|
|
86
|
-
? [
|
|
87
|
-
currencyField({
|
|
88
|
-
currenciesConfig,
|
|
89
|
-
}),
|
|
90
|
-
amountField({
|
|
91
|
-
currenciesConfig,
|
|
92
|
-
overrides: {
|
|
93
|
-
name: 'subtotal',
|
|
94
|
-
label: ({ t }) =>
|
|
95
|
-
// @ts-expect-error - translations are not typed in plugins yet
|
|
96
|
-
t('plugin-ecommerce:subtotal'),
|
|
97
|
-
},
|
|
98
|
-
}),
|
|
99
|
-
]
|
|
100
|
-
: []),
|
|
101
|
-
cartItemsField({
|
|
102
|
-
enableVariants,
|
|
103
|
-
overrides: {
|
|
104
|
-
label: ({ t }) =>
|
|
105
|
-
// @ts-expect-error - translations are not typed in plugins yet
|
|
106
|
-
t('plugin-ecommerce:items'),
|
|
107
|
-
labels: {
|
|
108
|
-
plural: ({ t }) =>
|
|
109
|
-
// @ts-expect-error - translations are not typed in plugins yet
|
|
110
|
-
t('plugin-ecommerce:items'),
|
|
111
|
-
singular: ({ t }) =>
|
|
112
|
-
// @ts-expect-error - translations are not typed in plugins yet
|
|
113
|
-
t('plugin-ecommerce:item'),
|
|
114
|
-
},
|
|
115
|
-
},
|
|
116
|
-
productsSlug,
|
|
117
|
-
variantsSlug,
|
|
118
|
-
}),
|
|
119
|
-
]
|
|
120
|
-
|
|
121
|
-
const fields =
|
|
122
|
-
fieldsOverride && typeof fieldsOverride === 'function'
|
|
123
|
-
? fieldsOverride({ defaultFields })
|
|
124
|
-
: defaultFields
|
|
125
|
-
|
|
126
|
-
const baseConfig: CollectionConfig = {
|
|
127
|
-
slug: 'carts',
|
|
128
|
-
timestamps: true,
|
|
129
|
-
...overrides,
|
|
130
|
-
admin: {
|
|
131
|
-
useAsTitle: 'createdAt',
|
|
132
|
-
...overrides?.admin,
|
|
133
|
-
},
|
|
134
|
-
fields,
|
|
135
|
-
hooks: {
|
|
136
|
-
beforeChange: [
|
|
137
|
-
// This hook can be used to update the subtotal before saving the cart
|
|
138
|
-
beforeChangeCart({ productsSlug, variantsSlug }),
|
|
139
|
-
...(overrides?.hooks?.beforeChange || []),
|
|
140
|
-
],
|
|
141
|
-
...overrides?.hooks,
|
|
142
|
-
},
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
return { ...baseConfig }
|
|
146
|
-
}
|
package/src/currencies/index.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { Currency } from '../types.js'
|
|
2
|
-
|
|
3
|
-
export const EUR: Currency = {
|
|
4
|
-
code: 'EUR',
|
|
5
|
-
decimals: 2,
|
|
6
|
-
label: 'Euro',
|
|
7
|
-
symbol: '€',
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const USD: Currency = {
|
|
11
|
-
code: 'USD',
|
|
12
|
-
decimals: 2,
|
|
13
|
-
label: 'US Dollar',
|
|
14
|
-
symbol: '$',
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const GBP: Currency = {
|
|
18
|
-
code: 'GBP',
|
|
19
|
-
decimals: 2,
|
|
20
|
-
label: 'British Pound',
|
|
21
|
-
symbol: '£',
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const JPY: Currency = {
|
|
25
|
-
code: 'JPY',
|
|
26
|
-
decimals: 0,
|
|
27
|
-
label: 'Japanese Yen',
|
|
28
|
-
symbol: '¥',
|
|
29
|
-
}
|