@bingtsingw/orchid-helper 1.0.0 → 1.0.1

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/index.js CHANGED
@@ -1 +1 @@
1
- import{cuid2 as s}from"@xstools/utility/cuid2";import{uuid25encode as i}from"@xstools/utility/string";import{createBaseTable as d}from"orchid-orm";import{v7 as m}from"uuid";var o=e=>()=>e.string(36).primaryKey().default(()=>s()),l=e=>()=>e.string(36).primaryKey().default(()=>{let t="";return typeof Bun<"u"?t=Bun.randomUUIDv7():t=m(),i(t)}),f=e=>()=>e.string(36).primaryKey().default(()=>s(6)),n=e=>()=>e.timestampsNoTZ().createdAt.default(()=>new Date().toISOString()).asDate(),r=e=>()=>e.timestampsNoTZ().updatedAt.default(()=>new Date().toISOString()).asDate(),u=e=>()=>e.timestampNoTZ().asDate().nullable(),D=d({snakeCase:!0,nowSQL:"now()::timestamptz(3) AT TIME ZONE 'UTC'",columnTypes:e=>({...e,xEnum:t=>e.string().narrowType(a=>a()),xJsonText:()=>e.jsonText().encode(t=>{if(typeof t!="object")throw new Error("Invalid value for JSON column");return JSON.stringify(t)}),xTimestamp:()=>e.timestampNoTZ().asDate(),createdAt:n(e),updatedAt:r(e),deletedAt:u(e),cuid:o(e),baseColumns:t=>({id:t?.strategy==="cuid2"?o(e)():t?.strategy==="shortid"?f(e)():l(e)(),createdAt:n(e)(),updatedAt:r(e)(),deletedAt:u(e)()})})});export{D as BaseTable};
1
+ import{cuid2 as s}from"@xstools/utility/cuid2";import{uuid25encode as i}from"@xstools/utility/string";import{createBaseTable as m}from"orchid-orm";import{v7 as d}from"uuid";var o=e=>()=>e.string(36).primaryKey().default(()=>s()),l=e=>()=>e.string(36).primaryKey().default(()=>{let t="";return typeof Bun<"u"?t=Bun.randomUUIDv7():t=d(),i(t)}),f=e=>()=>e.string(36).primaryKey().default(()=>s(6)),n=e=>()=>e.timestampsNoTZ().createdAt.default(()=>new Date().toISOString()).asDate(),r=e=>()=>e.timestampsNoTZ().updatedAt.default(()=>new Date().toISOString()).asDate(),u=e=>()=>e.timestampNoTZ().asDate().nullable(),D=m({snakeCase:!0,nowSQL:"clock_timestamp()::timestamptz(3) AT TIME ZONE 'UTC'",columnTypes:e=>({...e,xEnum:t=>e.string().narrowType(a=>a()),xJsonText:()=>e.jsonText().encode(t=>{if(typeof t!="object")throw new Error("Invalid value for JSON column");return JSON.stringify(t)}),xTimestamp:()=>e.timestampNoTZ().asDate(),createdAt:n(e),updatedAt:r(e),deletedAt:u(e),cuid:o(e),baseColumns:t=>({id:t?.strategy==="cuid2"?o(e)():t?.strategy==="shortid"?f(e)():l(e)(),createdAt:n(e)(),updatedAt:r(e)(),deletedAt:u(e)()})})});export{D as BaseTable};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bingtsingw/orchid-helper",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/bingtsingw/orchid-helper.git",
@@ -22,10 +22,10 @@
22
22
  "uuid": "^13.0.0"
23
23
  },
24
24
  "devDependencies": {
25
- "orchid-orm": "1.62.0"
25
+ "orchid-orm": "1.62.1"
26
26
  },
27
27
  "peerDependencies": {
28
- "orchid-orm": "^1.62.0"
28
+ "orchid-orm": "^1.62.1"
29
29
  },
30
30
  "publishConfig": {
31
31
  "access": "public",
package/src/base-table.ts CHANGED
@@ -46,7 +46,7 @@ const deletedAt = (t: DefaultColumnTypes<DefaultSchemaConfig>) => () => t.timest
46
46
 
47
47
  export const BaseTable = createBaseTable({
48
48
  snakeCase: true,
49
- nowSQL: `now()::timestamptz(3) AT TIME ZONE 'UTC'`,
49
+ nowSQL: `clock_timestamp()::timestamptz(3) AT TIME ZONE 'UTC'`,
50
50
 
51
51
  columnTypes: (t) => ({
52
52
  ...t,