@opengis/fcore 0.0.1-beta.17 → 0.0.1-beta.19
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/LICENSE +3 -3
- package/README.md +71 -71
- package/dist/config.js +1 -1
- package/dist/context.js +1 -1
- package/dist/errors.js +1 -1
- package/dist/fastify.d.ts.map +1 -1
- package/dist/fastify.js +1 -1
- package/dist/fcore.js +1 -1
- package/dist/migrations/cli.js +1 -1
- package/dist/migrations/runner.js +1 -1
- package/dist/modules/auth/adduser-cli.js +1 -1
- package/dist/modules/auth/passwd-cli.js +1 -1
- package/dist/modules/auth/permission-cli.js +1 -1
- package/dist/modules/auth/route.js +1 -1
- package/dist/modules/auth/schema.js +1 -1
- package/dist/modules/auth/services/change-password.js +1 -1
- package/dist/modules/auth/services/get-current-user.js +1 -1
- package/dist/modules/auth/services/registration.js +1 -1
- package/dist/modules/auth/services/verify-two-factor.js +1 -1
- package/dist/modules/file/mime.js +1 -1
- package/dist/modules/file/route.js +1 -1
- package/dist/modules/file/schema.js +1 -1
- package/dist/modules/file/services/get-file.js +1 -1
- package/dist/modules/file/services/resize-file.js +1 -1
- package/dist/modules/file/services/upload-file.js +1 -1
- package/dist/modules/resource/route.js +1 -1
- package/dist/modules/resource/schema.js +1 -1
- package/dist/modules/resource/services/add-note.js +1 -1
- package/dist/modules/resource/services/add-resource-file.js +1 -1
- package/dist/modules/resource/services/create-resource-relation.js +1 -1
- package/dist/modules/resource/services/create-resource.js +1 -1
- package/dist/modules/resource/services/delete-resource-relation.js +1 -1
- package/dist/modules/resource/services/delete-resource.js +1 -1
- package/dist/modules/resource/services/export-resource.js +1 -1
- package/dist/modules/resource/services/get-resource.js +1 -1
- package/dist/modules/resource/services/list-resource-relation.js +1 -1
- package/dist/modules/resource/services/list-resources.js +1 -1
- package/dist/modules/resource/services/search-resource.js +1 -1
- package/dist/modules/resource/services/suggest-resource.js +1 -1
- package/dist/modules/resource/services/update-resource-relation.js +1 -1
- package/dist/modules/resource/services/update-resource.js +1 -1
- package/dist/modules/resource/services/upload-resource-file.js +1 -1
- package/dist/modules/system/route.js +1 -1
- package/dist/modules/system/schema.d.ts +3 -2
- package/dist/modules/system/schema.d.ts.map +1 -1
- package/dist/modules/system/schema.js +1 -1
- package/dist/modules/system/services/check-system.js +1 -1
- package/dist/modules/system/services/get-access.d.ts +1 -0
- package/dist/modules/system/services/get-access.d.ts.map +1 -1
- package/dist/modules/system/services/get-access.js +1 -1
- package/dist/modules/system/services/get-api-list.js +1 -1
- package/dist/modules/system/services/get-audit-log.js +1 -1
- package/dist/modules/system/services/get-dictionary.js +1 -1
- package/dist/modules/system/services/get-system-log.js +1 -1
- package/dist/modules/system/services/get-system-settings.js +1 -1
- package/dist/modules/system/services/list-dictionaries.js +1 -1
- package/dist/modules/system/services/set-access.d.ts +2 -1
- package/dist/modules/system/services/set-access.d.ts.map +1 -1
- package/dist/modules/system/services/set-access.js +1 -1
- package/dist/modules/system/services/update-dictionary.js +1 -1
- package/dist/modules/system/services/update-system-settings.js +1 -1
- package/dist/modules/utils/require-admin.js +1 -1
- package/dist/modules/utils/safe-user.js +1 -1
- package/dist/modules/utils/unsupported.js +1 -1
- package/dist/plugins/audit/audit.js +1 -1
- package/dist/plugins/audit/audit.types.d.ts +1 -1
- package/dist/plugins/audit/audit.types.d.ts.map +1 -1
- package/dist/plugins/audit/services/write-audit.js +1 -1
- package/dist/plugins/auth/get-user-permissions.js +1 -1
- package/dist/plugins/auth/index.js +1 -1
- package/dist/plugins/auth/verifyUser.js +1 -1
- package/dist/plugins/dictionary.js +1 -1
- package/dist/plugins/file.js +1 -1
- package/dist/plugins/jwt.js +1 -1
- package/dist/plugins/logger/index.js +1 -1
- package/dist/plugins/logger/transport.js +1 -1
- package/dist/plugins/pg.js +1 -1
- package/dist/plugins/redis.js +1 -1
- package/dist/plugins/resource/resource.js +1 -1
- package/dist/plugins/resource/resource.registry.js +1 -1
- package/dist/plugins/resource/resource.types.d.ts +3 -4
- package/dist/plugins/resource/resource.types.d.ts.map +1 -1
- package/dist/plugins/resource/services/add-dictionary-lookup-data.js +1 -1
- package/dist/plugins/resource/services/add-file-token.js +1 -1
- package/dist/plugins/resource/services/add-table-lookup-data.js +1 -1
- package/dist/plugins/resource/services/create-relation.js +1 -1
- package/dist/plugins/resource/services/create.js +1 -1
- package/dist/plugins/resource/services/delete-relation.js +1 -1
- package/dist/plugins/resource/services/delete.d.ts.map +1 -1
- package/dist/plugins/resource/services/delete.js +1 -1
- package/dist/plugins/resource/services/find-one.d.ts.map +1 -1
- package/dist/plugins/resource/services/find-one.js +1 -1
- package/dist/plugins/resource/services/find-relation.d.ts.map +1 -1
- package/dist/plugins/resource/services/find-relation.js +1 -1
- package/dist/plugins/resource/services/find.d.ts.map +1 -1
- package/dist/plugins/resource/services/find.js +1 -1
- package/dist/plugins/resource/services/update-relation.js +1 -1
- package/dist/plugins/resource/services/update.d.ts.map +1 -1
- package/dist/plugins/resource/services/update.js +1 -1
- package/dist/plugins/resource/utils/auto-index.js +1 -1
- package/dist/plugins/resource/utils/fields.js +1 -1
- package/dist/plugins/resource/utils/filters.js +1 -1
- package/dist/plugins/resource/utils/permissions.js +1 -1
- package/dist/plugins/resource/utils/sort.d.ts +1 -1
- package/dist/plugins/resource/utils/sort.d.ts.map +1 -1
- package/dist/plugins/resource/utils/sort.js +1 -1
- package/dist/plugins/resource/utils/sql.js +1 -1
- package/dist/shared/getIP.js +1 -1
- package/migrations/20260903130000_move_notes_files_to_admin.sql +17 -17
- package/migrations/20260903140000_settings_nulls_not_distinct.sql +18 -18
- package/migrations/20260905120000_add_user_foreign_keys.sql +42 -42
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function Z(){const T=['slice','mkdirSync','createWriteStream','.log','stream','set','clear','file'];Z=function(){return T;};return Z();}import L from'node:fs';import E from'node:path';import c from'pino-abstract-transport';const LEVELS={0x1e:'info',0x28:'warn',0x32:'error',0x3c:'error'},streams=new Map();function getDate(){const r=O;return new Date()['toISOString']()[r(0x18e)](0x0,0xa);}function createStream(t,e){const X=O,B=E['resolve']('logs',t);return L[X(0x18f)](B,{'recursive':!![]}),L[X(0x190)](E['join'](B,e+X(0x191)),{'flags':'a'});}function getStream(t){const j=O,e=getDate(),B=streams['get'](t);if(B&&B['date']===e)return B['stream'];B?.[j(0x192)]['end']();const g=createStream(t,e);return streams[j(0x193)](t,{'date':e,'stream':g}),g;}function closeStreams(){const F=O;for(const {stream:t}of streams['values']()){t['end']();}streams[F(0x194)]();}function O(L,E){L=L-0x18e;const c=Z();let t=c[L];return t;}export default async function loggerTransport(){return c(writeLogs,{'close':async()=>{closeStreams();}});}async function writeLogs(t){const I=O;for await(const e of t){const B=LEVELS[e['level']];if(!B)continue;const g=getStream(e['file']||B);delete e[I(0x195)],g['write'](JSON['stringify'](e)+'\x0a');}}
|
package/dist/plugins/pg.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import L from'pg';function Z(){const A=['query','bind','captureStackTrace','transaction','connect','BEGIN','ROLLBACK'];Z=function(){return A;};return Z();}const {Pool}=L;function O(L,E){L=L-0x6a;const c=Z();let t=c[L];return t;}export function createDatabase(E){const I=O,c=new Pool(E),t=c[I(0x6a)][I(0x6b)](c);function e(B,g){const T=I,r=new Error();return Error[T(0x6c)]?.(r,e),t(B,g)['catch'](X=>{const j=X;j['sql']=B,j['callerStack']=r['stack'];throw j;});}return c[I(0x6a)]=e,c['transaction']=async function(B){const f=I,g=new Error();Error[f(0x6c)]?.(g,c[f(0x6d)]);const r=await c[f(0x6e)]();try{await r['query'](f(0x6f));const X=await B(r);return await r['query']('COMMIT'),X;}catch(j){await r['query'](f(0x70));const F=j;F['callerStack']=g['stack'];throw F;}finally{r['release']();}},c;}
|
package/dist/plugins/redis.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
import{Redis}from'ioredis';function O(L,E){L=L-0xc6;const c=Z();let t=c[L];return t;}function Z(){const r=['del','ping'];Z=function(){return r;};return Z();}export function createRedis(L){const g=O,E=new Redis(L);return{'get':c=>E['get'](c),'set':(c,t,e,B)=>{if(B)return E['set'](c,t,'EX',B);if(typeof e==='number')return E['set'](c,t,'EX',e);return E['set'](c,t);},'del':c=>E['del'](c),'delete':c=>E[g(0xc6)](c),'close':()=>E['quit'](),'ping':()=>E[g(0xc7)](),'hincrby':(c,t,e)=>E['hincrby'](c,t,e),'incrby':(c,t)=>E['incrby'](c,t)};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ResourceRegistry}from'./resource.registry.js';
|
|
1
|
+
import{ResourceRegistry}from'./resource.registry.js';import{createFind}from'./services/find.js';import{createFindOne}from'./services/find-one.js';import{createCreate}from'./services/create.js';import{createUpdate}from'./services/update.js';import{createRemove}from'./services/delete.js';import{createFindRelation}from'./services/find-relation.js';import{createCreateRelation}from'./services/create-relation.js';import{createDeleteRelation}from'./services/delete-relation.js';import{createUpdateRelation}from'./services/update-relation.js';export function createResource(L){const E=new ResourceRegistry(),c=createFind(L,E),t=createFindOne(L,E),e=createCreate(L,E),B=createUpdate(L,E),g=createRemove(L,E),r=createFindRelation(L,E),X=createCreateRelation(L,E),j=createUpdateRelation(L,E),F=createDeleteRelation(L,E);return{'register':E['register']['bind'](E),'has':E['has']['bind'](E),'get':E['get']['bind'](E),'list':E['list']['bind'](E),'find':c,'findOne':t,'create':e,'update':B,'delete':g,'findRelation':r,'createRelation':X,'updateRelation':j,'deleteRelation':F};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function O(L,E){L=L-0xa9;const c=Z();let t=c[L];return t;}function Z(){const j=['isArray','name','has','resources','Resource\x20not\x20registered:\x20','values','test','table','key'];Z=function(){return j;};return Z();}const e=O;import{ValidationError,ConflictError,NotFoundError}from'../../errors.js';const ident=/^[a-zA-Z0-9_-]*$/;function validQualified(L){return L['split']('.')['length']<=0x2&&L['split']('.')['every'](E=>ident['test'](E));}export class ResourceRegistry{['resources']=new Map();['register'](L){const t=O;for(const E of Array[t(0xa9)](L)?L:[L]){this['validate'](E);if(this['resources']['has'](E['name']))throw new ConflictError('Resource\x20already\x20registered:\x20'+E['name']);this['resources']['set'](E[t(0xaa)],E);}}[e(0xab)](L){const B=e;return this[B(0xac)][B(0xab)](L);}['get'](L){const g=e,E=this['resources']['get'](L);if(!E)throw new NotFoundError(g(0xad)+L);return E;}['list'](){const r=e;return[...this['resources'][r(0xae)]()];}['validate'](L){const X=e;if(L['version']!==0x1||!ident[X(0xaf)](L['name'])||!validQualified(L[X(0xb0)])||!ident[X(0xaf)](L[X(0xb1)]))throw new ValidationError('Invalid\x20resource\x20contract:\x20'+L[X(0xaa)]);for(const [E,c]of Object['entries'](L['fields'])){if(!ident['test'](E)||!ident['test'](c['column']??E))throw new ValidationError('Invalid\x20resource\x20field:\x20'+E);}}}
|
|
@@ -26,8 +26,6 @@ export interface ResourceFieldContract {
|
|
|
26
26
|
searchable?: boolean;
|
|
27
27
|
sortable?: boolean;
|
|
28
28
|
filter?: boolean;
|
|
29
|
-
sort?: boolean;
|
|
30
|
-
search?: boolean;
|
|
31
29
|
scope?: "all" | "item";
|
|
32
30
|
dictionary?: string;
|
|
33
31
|
lookup?: {
|
|
@@ -46,9 +44,9 @@ export interface ResourceFieldContract {
|
|
|
46
44
|
export interface ResourceRelationContract {
|
|
47
45
|
resource?: string;
|
|
48
46
|
table?: string;
|
|
47
|
+
where?: string;
|
|
49
48
|
localKey?: string;
|
|
50
49
|
foreignKey?: string;
|
|
51
|
-
type?: "one" | "many";
|
|
52
50
|
fields?: string[];
|
|
53
51
|
junctionTable?: string;
|
|
54
52
|
junctionLocalKey?: string;
|
|
@@ -57,9 +55,10 @@ export interface ResourceRelationContract {
|
|
|
57
55
|
export interface ResourceContract {
|
|
58
56
|
version: 1;
|
|
59
57
|
name: string;
|
|
60
|
-
module
|
|
58
|
+
module?: string;
|
|
61
59
|
title?: string;
|
|
62
60
|
table: string;
|
|
61
|
+
where?: string;
|
|
63
62
|
key: string;
|
|
64
63
|
operations: ResourceOperation[];
|
|
65
64
|
searchable?: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource.types.d.ts","sourceRoot":"","sources":["../../../src/plugins/resource/resource.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;AACxE,MAAM,WAAW,oBAAoB;
|
|
1
|
+
{"version":3,"file":"resource.types.d.ts","sourceRoot":"","sources":["../../../src/plugins/resource/resource.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,MAAM,MAAM,iBAAiB,G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AE,MAAM,CAAC;QACjB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC/B,IAAI,CAAC,EAAE,YAAY,CAAC;KACrB,EAAE,GAAG,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IACnC,cAAc,CAAC,MAAM,EAAE;QACrB,IAAI,EAAE,MAAM,CAAC;QACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;QACpB,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;QACnB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC9B,IAAI,CAAC,EAAE,YAAY,CAAC;KACrB,EAAE,GAAG,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACvD,cAAc,CAAC,MAAM,EAAE;QACrB,IAAI,EAAE,MAAM,CAAC;QACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;QACpB,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;QACnB,IAAI,CAAC,EAAE,YAAY,CAAC;KACrB,EAAE,GAAG,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;CACrD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function O(L,E){L=L-0x1e0;const c=Z();let t=c[L];return t;}function Z(){const A=['set','all','has','get','color','icon','length','flatMap'];Z=function(){return A;};return Z();}const dictionaryIndexesCache=new WeakMap(),dictionaryRevisionsCache=new WeakMap();async function getDictionaryIndexes(L,E){const I=O,c=dictionaryIndexesCache['get'](E)??new Map(),t=dictionaryRevisionsCache['get'](E)??new Map();dictionaryIndexesCache['set'](E,c),dictionaryRevisionsCache[I(0x1e0)](E,t);const e=L['filter'](g=>t['get'](g)!==E['revision'](g));if(e['length']===0x0)return c;const B=await Promise[I(0x1e1)](e['map'](async g=>{const T=I;if(!E[T(0x1e2)](g))return[g,new Map()];const r=await E[T(0x1e3)](g),X=new Map();for(const j of r){const F=j['code']??j['id'];if(F==null)continue;X[T(0x1e0)](String(F),{'id':F,'text':j['name']??j['text'],...j['color']!==undefined?{'color':j[T(0x1e4)]}:{},...j['icon']!==undefined?{'icon':j[T(0x1e5)]}:{}});}return[g,X];}));for(const [g,r]of B){c['set'](g,r),t['set'](g,E['revision'](g));}return c;}export async function addDictionaryLookupData(L,E,c){const f=O;if(!c||L[f(0x1e6)]===0x0)return L;const t=Object['entries'](E)[f(0x1e7)](([B,g])=>{const r=g['dictionary'];return r?[{'field':B,'dictionaryName':r}]:[];});if(t['length']===0x0)return L;const e=await getDictionaryIndexes([...new Set(t['map'](({dictionaryName:B})=>B))],c);for(const B of L){for(const {field:g,dictionaryName:r}of t){const X=B[g];B[g+'_data']=X==null?null:e['get'](r)?.['get'](String(X))??null;}}return L;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export function addFileToken(L,E,c){const r=O;if(!c||L['length']===0x0)return L;const t=Object['entries'](E)[r(0xe5)](([,e])=>e[r(0xe6)]===r(0xe7))['map'](([e])=>e);for(const e of L){for(const B of t){const g=e[B];typeof g==='string'&&g[r(0xe8)]>0x0&&(e[B]=c['create'](g));}}return L;}function O(L,E){L=L-0xe5;const c=Z();let t=c[L];return t;}function Z(){const X=['filter','type','file','length'];Z=function(){return X;};return Z();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{qi,qt}from'../utils/sql.js';function Z(){const q=['entries','string','number','has','query','SELECT\x20','\x20AS\x20id,\x20','\x20AS\x20text\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20','set','field','_data'];Z=function(){return q;};return Z();}const tableLookupCache=new WeakMap();export function clearTableLookupCache(L,E){const c=tableLookupCache['get'](E);if(!c)return;for(const t of c['keys']()){t['startsWith'](L+':')&&c['delete'](t);}}function O(L,E){L=L-0x68;const c=Z();let t=c[L];return t;}export async function addTableLookupData(L,E,c){const W=O;if(!c||L['length']===0x0)return L;const t=tableLookupCache['get'](c)??new Map();tableLookupCache['set'](c,t);const e=Object[W(0x68)](E)['flatMap'](([B,g])=>{const {table:r,value:value='id',text:text='name'}=g['lookup']??{};return r?[{'field':B,'table':r,'value':value,'text':text}]:[];});for(const B of e){const g=new Map();for(const F of L){const I=F[B['field']];(typeof I===W(0x69)||typeof I===W(0x6a))&&g['set'](String(I),I);}const r=B['table']+':'+B['value']+':'+B['text'],X=t['get'](r)??new Map();t['set'](r,X);const j=[...g['entries']()]['filter'](([T])=>!X[W(0x6b)](T))['map'](([,T])=>T);if(j['length']>0x0){const T=await c[W(0x6c)](W(0x6d)+qi(B['value'])+W(0x6e)+qi(B['text'])+W(0x6f)+qt(B['table'])+'\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20'+qi(B['value'])+'\x20=\x20ANY($1)',[j]);for(const f of T['rows']){X[W(0x70)](String(f['id']),f);}for(const A of j){!X[W(0x6b)](String(A))&&X[W(0x70)](String(A),null);}}for(const G of L){const x=G[B['field']];G[B[W(0x71)]+W(0x72)]=x==null?null:X['get'](String(x))??null;}}return L;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{UnsupportedError}from'../../../errors.js';function
|
|
1
|
+
function Z(){const W=['files','includes','capabilities','INSERT\x20INTO\x20admin.notes(resource,resource_id,body)\x20VALUES\x20($1,$2,$3)\x20RETURNING\x20*','INSERT\x20INTO\x20admin.files\x20(resource,\x20resource_id,\x20file_path,\x20size)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20RETURNING\x20*','filePath','size','rows','relations','resource','table','Generic\x20Resource\x20relation\x20\x22','\x22\x20requires\x20a\x20project/provider\x20implementation'];Z=function(){return W;};return Z();}import{UnsupportedError}from'../../../errors.js';function O(L,E){L=L-0x138;const c=Z();let t=c[L];return t;}import{createCreate}from'./create.js';export function createCreateRelation(L,E){const c=createCreate(L,E);return async function t({name:e,id:B,relation:g,data:r,user:X},j){const x=O,F=j?.['pg']??L['pg'],I=E['get'](e);if(['notes',x(0x138)][x(0x139)](g)&&!I[x(0x13a)]?.['includes'](g))throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+g+'\x22\x20requires\x20a\x20capabilities\x20\x22'+g+'\x22');if(g==='notes'){const A=await F['query'](x(0x13b),[e,String(B),r?.['body']]);return A['rows'][0x0];}if(g==='files'){const G=await F['query'](x(0x13c),[e,String(B),r?.[x(0x13d)],r?.[x(0x13e)]??null]);return G[x(0x13f)][0x0];}const T=I[x(0x140)]?.[g];if(!T?.['foreignKey']||!T[x(0x141)]&&!T[x(0x142)])throw new UnsupportedError(x(0x143)+g+x(0x144));if(!r)throw new UnsupportedError('No\x20data\x20provided\x20for\x20relation:\x20'+r);if(!T['resource'])throw new UnsupportedError('Relation\x20update\x20is\x20not\x20configured:\x20'+g);r[T['foreignKey']]=B;const f=await c({'name':T['resource'],'data':r??{},'user':X});return f;};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function O(L,E){L=L-0x10b;const c=Z();let t=c[L];return t;}function Z(){const q=['fields','No\x20writable\x20fields','map','join','audit','write','module'];Z=function(){return q;};return Z();}import{ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';import{qi,qt,writableData}from'../utils/sql.js';import{validateInputData}from'../utils/fields.js';import{clearTableLookupCache}from'./add-table-lookup-data.js';export function createCreate(L,E){return async function c({name:t,data:e,user:B},g){const W=O,r=E['get'](t);assertOperation(r,'create',B),validateInputData({'resource':r,'data':e});const X=writableData(r,e);r['fields']['created_at']&&X['push'](['created_at',new Date()]);r[W(0x10b)]['created_by']&&X['push'](['created_by',B?.['id']]);if(!X['length'])throw new ValidationError(W(0x10c));const j=X['map'](([G])=>qi(G)),F=X[W(0x10d)]((G,x)=>'$'+(x+0x1)),I=X['map'](([,G])=>G),T=g?.['pg']??L['pg'],f=await T['query']('INSERT\x20INTO\x20'+qt(r['table'])+'\x20('+j[W(0x10e)](',\x20')+')\x20'+('VALUES\x20('+F['join'](',\x20')+')\x20')+'RETURNING\x20*',I),A=f['rows'][0x0];return clearTableLookupCache(r['table'],T),await(g?.[W(0x10f)]??L['audit'])?.[W(0x110)]({'userId':B?.['id'],'module':r[W(0x111)],'resource':r['name'],'resourceId':A[r['key']],'action':'create','fields':Object['keys'](e)}),A;};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{UnsupportedError}from'../../../errors.js';import{createRemove}from'./delete.js';function
|
|
1
|
+
import{UnsupportedError}from'../../../errors.js';import{createRemove}from'./delete.js';function Z(){const G=['get','includes','notes','query','relations','resource','foreignKey'];Z=function(){return G;};return Z();}function O(L,E){L=L-0x81;const c=Z();let t=c[L];return t;}export function createDeleteRelation(L,E){const c=createRemove(L,E);return async function t({name:e,id:B,relation:g,relationId:r,user:X},j){const A=O,F=j?.['pg']??L['pg'],I=E[A(0x81)](e);if(['notes','files'][A(0x82)](g)&&!I['capabilities']?.[A(0x82)](g))throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+g+'\x22\x20requires\x20a\x20capabilities\x20\x22'+g+'\x22');if(g===A(0x83))return await F['query']('DELETE\x20FROM\x20admin.notes\x20WHERE\x20note_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3',[r,e,String(B)]),{'success':!![]};if(g==='files')return await F[A(0x84)]('DELETE\x20FROM\x20admin.files\x20WHERE\x20file_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3',[r,e,String(B)]),{'success':!![]};const T=I[A(0x85)]?.[g];if(!T?.[A(0x86)]||!T[A(0x87)])throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+g+'\x22\x20requires\x20a\x20project/provider\x20implementation');const f=await c({'name':T[A(0x86)],'id':r,'user':X,'where':{'column':T[A(0x87)],'value':B}},j);return{'success':f};};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/delete.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAI/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,KAAK,YAAY,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,KAAK,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;CACpD,CAAC;AACF,wBAAgB,YAAY,CAC1B,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,gCAE+B,YAAY,QAAQ,UAAU,
|
|
1
|
+
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/delete.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAI/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,KAAK,YAAY,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,KAAK,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;CACpD,CAAC;AACF,wBAAgB,YAAY,CAC1B,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,gCAE+B,YAAY,QAAQ,UAAU,sBAoCxF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{assertOperation}from'../utils/permissions.js';function
|
|
1
|
+
function O(L,E){L=L-0x17e;const c=Z();let t=c[L];return t;}import{assertOperation}from'../utils/permissions.js';import{qt,qi}from'../utils/sql.js';function Z(){const A=['delete','\x20=\x20$','where','\x20AND\x20(','DELETE\x20FROM\x20','audit','write'];Z=function(){return A;};return Z();}import{clearTableLookupCache}from'./add-table-lookup-data.js';export function createRemove(L,E){return async function c({name:t,id:e,user:B,where:g},r){const f=O,X=E['get'](t);assertOperation(X,f(0x17e),B);const j=r?.['pg']??L['pg'],F=[e];let I='WHERE\x20'+qi(X['key'])+'\x20=\x20$1';g&&(F['push'](g['value']),I+='\x20AND\x20'+qi(g['column'])+f(0x17f)+F['length']);X[f(0x180)]&&(I+=f(0x181)+X['where']+')');const T=await j['query'](f(0x182)+qt(X['table'])+'\x20'+I,F);if((T['rowCount']??0x0)>0x0)clearTableLookupCache(X['table'],j);if((T['rowCount']??0x0)>0x0)await(r?.[f(0x183)]??L['audit'])?.[f(0x184)]({'module':X['module'],'resource':X['name'],'resourceId':e,'action':'delete'});return(T['rowCount']??0x0)>0x0;};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find-one.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find-one.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAK9F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAKhE,wBAAgB,aAAa,CAC3B,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,gCAOvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,
|
|
1
|
+
{"version":3,"file":"find-one.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find-one.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAK9F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAKhE,wBAAgB,aAAa,CAC3B,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,gCAOvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,6CAuDF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';import{qt,qi,readableFields}from'../utils/sql.js';import{addDictionaryLookupData}from'./add-dictionary-lookup-data.js';
|
|
1
|
+
import{ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';import{qt,qi,readableFields}from'../utils/sql.js';import{addDictionaryLookupData}from'./add-dictionary-lookup-data.js';import{addTableLookupData}from'./add-table-lookup-data.js';import{addFileToken}from'./add-file-token.js';export function createFindOne(L,E){return async function c({name:t,id:e,query:query={},user:B}){const Y=O,g=Date['now'](),r=E['get'](t);assertOperation(r,Y(0xd4),B);if(r['fields'][r['key']]?.['type']==='integer'&&!Number['isInteger'](Number(e)))throw new ValidationError(Y(0xd5)+e+'\x20name:'+t);const X=r['joins']?.['map'](f=>f[Y(0xd6)]+'\x20')['join']('\x20')||'',j=r['where']?'\x20AND\x20('+r[Y(0xd7)]+')':'',F=await L['pg']['query']('SELECT\x20'+readableFields(r)['join'](',\x20')+Y(0xd8)+qt(r['table'])+'\x20t\x20'+X+'\x20WHERE\x20'+qi(r['key'])+'=$1'+j+'\x20LIMIT\x201',[e]),I=F['rows'][0x0];if(!I)return null;await addDictionaryLookupData([I],r['fields'],L['dictionary']),await addTableLookupData([I],r['fields'],L['pg']),addFileToken([I],r['fields'],L['file']);const T=Array['isArray'](query['include'])?query['include']:query[Y(0xd9)]?.['split'](',')??[];for(const f of T){const A=r['relations']?.[f];if(!A?.[Y(0xda)]||!A[Y(0xdb)]&&!A['table'])throw new ValidationError('Unknown\x20relation:\x20'+f);const G=A['resource']?E['get'](A[Y(0xdb)]):undefined,x=A['table']??G['table'],W=G?.['key']??'id',q=G?readableFields(G)['join'](',\x20'):'*',y=Y(0xdc)+q+'\x20FROM\x20'+qt(x)+Y(0xdd)+qi(W)+'\x20=\x20(\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20'+qi(A['foreignKey'])+'\x20FROM\x20'+qt(r['table'])+'\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20'+qi(r['key'])+'\x20=\x20$1\x20LIMIT\x201\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20)',p=(await L['pg']['query'](y,[e]))[Y(0xde)];G&&(await addDictionaryLookupData(p,G['fields'],L['dictionary']),await addTableLookupData(p,G['fields'],L['pg']),addFileToken(p,G[Y(0xdf)],L['file'])),I[f]=p;}return I['time']=Date[Y(0xe0)]()-g,I;};}function O(L,E){L=L-0xd4;const c=Z();let t=c[L];return t;}function Z(){const h=['read','Invalid\x20id:\x20','sql','where','\x20FROM\x20','include','foreignKey','resource','SELECT\x20','\x20WHERE\x20','rows','fields','now'];Z=function(){return h;};return Z();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find-relation.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find-relation.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC9F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAQhE,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,oCAOvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,KAAG,OAAO,CAAC,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"find-relation.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find-relation.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC9F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAQhE,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,oCAOvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,KAAG,OAAO,CAAC,GAAG,CAAC,CAuGjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{UnsupportedError,ValidationError}from'../../../errors.js';import{qi,qt}from'../utils/sql.js';function
|
|
1
|
+
import{UnsupportedError,ValidationError}from'../../../errors.js';import{qi,qt}from'../utils/sql.js';function O(L,E){L=L-0x148;const c=Z();let t=c[L];return t;}import{addDictionaryLookupData}from'./add-dictionary-lookup-data.js';import{addTableLookupData}from'./add-table-lookup-data.js';import{addFileToken}from'./add-file-token.js';import{autoIndex}from'../utils/auto-index.js';export function createFindRelation(L,E){return async function c({name:t,id:e,relation:B,query:query={}}){const S=O,g=Date['now'](),r=Math['min'](Math[S(0x148)](query[S(0x149)]??0x14,0x1),0xc8),X=Math['max'](query['offset']??0x0,0x0);if(!Number[S(0x14a)](r)||!Number['isFinite'](X))throw new ValidationError(S(0x14b));const j=E['get'](t),F=j['relations']?.[B];if(['notes',S(0x14c)]['includes'](B)&&!j['capabilities']?.[S(0x14d)](B))throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+B+'\x22\x20requires\x20a\x20capabilities\x20\x22'+B+'\x22');if(B===S(0x14e)){const Y=await L['pg']['query'](S(0x14f),[t,String(e)]);return{'total':Y[S(0x150)][S(0x151)],'time':Date['now']()-g,'rows':Y['rows']};}if(B===S(0x14c)){const h=await L['pg'][S(0x152)](S(0x153),[t,String(e)]);return addFileToken(h[S(0x150)],{'file_path':{'type':S(0x154)}},L['file']),{'total':h['rows']['length'],'time':Date['now']()-g,'rows':h['rows']};}const I=!!(F?.['junctionTable']&&F['junctionLocalKey']&&F['junctionForeignKey']);if(!F||!I&&!F['foreignKey']&&!F['localKey']||!F['resource']&&!F['table'])throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+B+S(0x155));const T=F['resource']?E['get'](F[S(0x156)]):undefined,f=F['table']??T[S(0x157)],A=T?.['key']??'id',G=!I&&Object['keys'](T?.[S(0x158)]??{})['filter'](w=>T?.['fields'][w]?.['read']&&T?.['fields'][w]?.['scope']!==S(0x159))['map'](qi)['join'](',\x20'),x=F[S(0x158)]?.[S(0x15a)](',\x20')||G||'*';F['foreignKey']&&autoIndex(f,F['foreignKey'],'btree',L['pg']);const W=T?.['joins']?.['filter'](w=>w['scope']!==S(0x159))['map'](w=>w['sql']+'\x20')['join']('\x20')||'',q=F[S(0x15b)]?S(0x15c)+F['where']+')':'',y=(I?'SELECT\x20'+x+S(0x15d)+qt(f)+'\x20t\x20'+W+'\x0a\x20\x20\x20\x20\x20\x20\x20\x20JOIN\x20'+qt(F['junctionTable'])+'\x20j\x20ON\x20j.'+qi(F['junctionForeignKey'])+'\x20=\x20t.'+qi(A)+'\x0a\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20j.'+qi(F[S(0x15e)])+'\x20=\x20$1'+q+S(0x15f):'')||(F['foreignKey']?'SELECT\x20'+x+'\x20FROM\x20'+qt(f)+'\x20t\x20'+W+'\x20WHERE\x20t.'+qi(F['foreignKey'])+'\x20=\x20$1'+q+'\x20LIMIT\x20$2\x20OFFSET\x20$3':'SELECT\x20'+x+S(0x15d)+qt(f)+'\x20t\x20'+W+'\x20WHERE\x20t.'+qi(F['foreignKey']||A)+S(0x160)+qi(F[S(0x161)])+'\x20FROM\x20'+qt(j['table'])+'\x20where\x20'+qi(j['key'])+'\x20=\x20$1\x20limit\x201)'+q+S(0x162)),p=await L['pg']['query'](y,[e,r,X]);return T&&(await addDictionaryLookupData(p['rows'],T[S(0x158)],L['dictionary']),await addTableLookupData(p['rows'],T['fields'],L['pg']),addFileToken(p['rows'],T['fields'],L['file'])),{'limit':r,'offset':X,'total':p['rows'][S(0x151)],'time':Date['now']()-g,'rows':p['rows']??null};};}function Z(){const D=['max','limit','isFinite','Invalid\x20pagination','files','includes','notes','SELECT\x20*\x20FROM\x20admin.notes\x20WHERE\x20resource\x20=\x20$1\x20AND\x20resource_id\x20=\x20$2\x20ORDER\x20BY\x20created_at\x20DESC','rows','length','query','SELECT\x20*\x20FROM\x20admin.files\x20WHERE\x20resource\x20=\x20$1\x20AND\x20resource_id\x20=\x20$2\x20ORDER\x20BY\x20created_at\x20DESC','file','\x22\x20requires\x20a\x20project/provider\x20implementation','resource','table','fields','item','join','where','\x20AND\x20(','\x20FROM\x20','junctionLocalKey','\x0a\x20\x20\x20\x20\x20\x20\x20\x20LIMIT\x20$2\x20OFFSET\x20$3','\x20=\x20(select\x20','localKey','\x20LIMIT\x20$2\x20OFFSET\x20$3'];Z=function(){return D;};return Z();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,oBAAoB,EACpB,kBAAkB,EAClB,aAAa,EACb,YAAY,EACb,MAAM,sBAAsB,CAAC;AAK9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAMhE,wBAAgB,UAAU,CACxB,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,4BAMvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,KAAG,OAAO,CAAC,kBAAkB,CAAC,
|
|
1
|
+
{"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,oBAAoB,EACpB,kBAAkB,EAClB,aAAa,EACb,YAAY,EACb,MAAM,sBAAsB,CAAC;AAK9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAMhE,wBAAgB,UAAU,CACxB,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,4BAMvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,KAAG,OAAO,CAAC,kBAAkB,CAAC,CAmDhC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ValidationError}from'../../../errors.js';import{buildFilters}from'../utils/filters.js';import{assertOperation}from'../utils/permissions.js';import{buildSort}from'../utils/sort.js';import{qt,readableFields}from'../utils/sql.js';function
|
|
1
|
+
import{ValidationError}from'../../../errors.js';import{buildFilters}from'../utils/filters.js';import{assertOperation}from'../utils/permissions.js';import{buildSort}from'../utils/sort.js';import{qt,readableFields}from'../utils/sql.js';function O(L,E){L=L-0x1a1;const c=Z();let t=c[L];return t;}import{addDictionaryLookupData}from'./add-dictionary-lookup-data.js';import{addTableLookupData}from'./add-table-lookup-data.js';import{addFileToken}from'./add-file-token.js';import{autoIndex}from'../utils/auto-index.js';export function createFind(L,E){return async function c({name:t,query:query={},user:e}){const W=O,B=Date['now'](),g=E['get'](t);assertOperation(g,'read',e);const r=Math[W(0x1a1)](Math['max'](query['limit']??0x14,0x1),0xc8),X=Math['max'](query['offset']??0x0,0x0),j=buildFilters(g,query[W(0x1a2)],0x1,L['pg']);g['where']&&(j['sql']+=(j[W(0x1a3)]?'\x20AND\x20':'\x20WHERE\x20')+('('+g['where']+')'));const F=buildSort(g,query[W(0x1a4)]);if(!Number[W(0x1a5)](r)||!Number[W(0x1a5)](X))throw new ValidationError(W(0x1a6));const I=g[W(0x1a7)]||Object['keys'](g['fields'])['filter'](x=>g['fields'][x]?.['searchable']);query[W(0x1a8)]&&I[W(0x1a9)]&&(I[W(0x1aa)](x=>autoIndex(g[W(0x1ab)],x,'text',L['pg'])),j['values']['push'](query['search']['toLowerCase']()+'%'),j[W(0x1a3)]+=(j['sql']?'\x20AND\x20':'\x20WHERE\x20')+('\x20('+I?.[W(0x1aa)](x=>'lower('+qt(x)+W(0x1ac)+j['values']['length'])[W(0x1ad)]('\x20OR\x20')+')'));const T=g['joins']?.[W(0x1a2)](x=>x['scope']!=='item')['map'](x=>x['sql']+'\x20')['join']('\x20')||'',f='SELECT\x20'+readableFields(g,'all')['join'](',\x20')+'\x20'+('FROM\x20'+qt(g['table'])+'\x20t\x20')+(T+'\x20'+j['sql']+'\x20'+F+'\x20')+(W(0x1ae)+(j[W(0x1af)]['length']+0x1)+'\x20')+('OFFSET\x20$'+(j['values'][W(0x1a9)]+0x2)),A=await L['pg'][W(0x1b0)](f,[...j[W(0x1af)],r,X]),G=A[W(0x1b1)];return await addDictionaryLookupData(G,g[W(0x1b2)],L[W(0x1b3)]),await addTableLookupData(G,g['fields'],L['pg']),addFileToken(G,g['fields'],L[W(0x1b4)]),{'limit':r,'offset':X,'total':A[W(0x1b5)],'time':Date['now']()-B,'rows':G};};}function Z(){const q=['min','filter','sql','sort','isFinite','Invalid\x20pagination','searchable','search','length','map','table',')\x20LIKE\x20$','join','LIMIT\x20$','values','query','rows','fields','dictionary','file','rowCount'];Z=function(){return q;};return Z();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{UnsupportedError,ValidationError}from'../../../errors.js';import{createUpdate}from'./update.js';function
|
|
1
|
+
import{UnsupportedError,ValidationError}from'../../../errors.js';import{createUpdate}from'./update.js';function Z(){const A=['relations','Relation\x20update\x20is\x20not\x20configured:\x20','resource','foreignKey'];Z=function(){return A;};return Z();}function O(L,E){L=L-0x11e;const c=Z();let t=c[L];return t;}export function createUpdateRelation(L,E){const c=createUpdate(L,E);return async function t({name:e,id:B,relation:g,relationId:r,data:X,user:j},F){const f=O,I=E['get'](e),T=I[f(0x11e)]?.[g];if(!T?.['resource']||!T['foreignKey'])throw new UnsupportedError(f(0x11f)+g);if(Object['hasOwn'](X,T['foreignKey'])&&X[T['foreignKey']]!==B)throw new ValidationError('Cannot\x20change\x20relation:\x20'+T['foreignKey']);return c({'name':T[f(0x120)],'id':r,'data':X,'user':j,'where':{'column':T[f(0x121)],'value':B}},F);};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/update.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAG/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAGhE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,KAAK,YAAY,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,KAAK,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;CACpD,CAAC;AACF,wBAAgB,YAAY,CAC1B,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,sCAEqC,YAAY,QAAQ,UAAU,KAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/update.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAG/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAGhE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,KAAK,YAAY,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,KAAK,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;CACpD,CAAC;AACF,wBAAgB,YAAY,CAC1B,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,sCAEqC,YAAY,QAAQ,UAAU,KAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CA2DjI"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{NotFoundError,ValidationError}from'../../../errors.js';
|
|
1
|
+
import{NotFoundError,ValidationError}from'../../../errors.js';function Z(){const p=['length','updated_at','user_type','map','WHERE\x20','\x20AND\x20','where','table','RETURNING\x20','join'];Z=function(){return p;};return Z();}import{assertOperation}from'../utils/permissions.js';function O(L,E){L=L-0xd2;const c=Z();let t=c[L];return t;}import{qi,qt,writableData}from'../utils/sql.js';import{validateInputData}from'../utils/fields.js';import{clearTableLookupCache}from'./add-table-lookup-data.js';export function createUpdate(L,E){return async function c({name:t,id:e,data:B,user:g,where:r},X){const y=O,j=E['get'](t);assertOperation(j,'update',g);const F=writableData(j,B);if(!F[y(0xd2)])throw new ValidationError('No\x20writable\x20fields');const I=X?.['pg']??L['pg'];validateInputData({'resource':j,'data':B,'update':!![]});j['fields']['updated_at']&&F['push']([y(0xd3),new Date()]);j['fields']['updated_by']&&F['push'](['updated_by',g?.['id']]);delete B[y(0xd4)];const T=F['map'](([W],q)=>qi(W)+'\x20=\x20$'+(q+0x1)),f=[...F[y(0xd5)](([,W])=>W),e];let A=y(0xd6)+qi(j['key'])+'\x20=\x20$'+f['length'];r&&(f['push'](r['value']),A+=y(0xd7)+qi(r['column'])+'\x20=\x20$'+f['length']);j[y(0xd8)]&&(A+='\x20AND\x20('+j['where']+')');const G=await I['query']('UPDATE\x20'+qt(j[y(0xd9)])+'\x20'+('SET\x20'+T['join'](',\x20')+'\x20')+(A+'\x20')+(y(0xda)+Object['keys'](B)['map'](qi)[y(0xdb)](',\x20')),f),x=G['rows'][0x0];if(!x)throw new NotFoundError(t+':'+e);return clearTableLookupCache(j['table'],I),await(X?.['audit']??L['audit'])?.['write']({'userId':g?.['id'],'module':j['module'],'resource':j['name'],'resourceId':e,'action':'update','fields':Object['keys'](B)}),x;};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function O(L,E){L=L-0x152;const c=Z();let t=c[L];return t;}function Z(){const j=['split','public','SELECT\x201\x20FROM\x20pg_indexes\x20WHERE\x20schemaname\x20=\x20$1\x20AND\x20indexname\x20=\x20$2','query','\x20ON\x20',')\x20gin_trgm_ops)','\x20USING\x20'];Z=function(){return j;};return Z();}import{qi,qt}from'./sql.js';const requestedIndexes=new WeakMap();export function autoIndex(L,E,c='btree',t){const e=requestedIndexes['get'](t)??new Set();requestedIndexes['set'](t,e);const B=L+':'+E+':'+c;if(e['has'](B))return;e['add'](B),void ensureIndex(L,E,c,t)['catch'](()=>{e['delete'](B);});}async function ensureIndex(L,E,c,t){const X=O,e=L[X(0x152)]('.'),B=e['length']===0x2?e[0x0]:X(0x153),g=(L+'_'+E+'_'+c+'_idx')['replace'](/[^A-Za-z0-9_]/g,'_'),r=await t['query'](X(0x154),[B,g]);if(r['rowCount'])return;if(c==='text'){await t['query']('CREATE\x20EXTENSION\x20IF\x20NOT\x20EXISTS\x20pg_trgm'),await t[X(0x155)]('CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'+qi(g+'_l')+X(0x156)+qt(L)+'\x20USING\x20btree\x20(lower('+qi(E)+')\x20text_pattern_ops)'),await t[X(0x155)]('CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'+qi(g)+X(0x156)+qt(L)+'\x20USING\x20gin\x20(lower('+qi(E)+X(0x157));return;}await t['query']('CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'+qi(g)+'\x20ON\x20'+qt(L)+X(0x158)+c+'\x20('+qi(E)+')');}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{ValidationError}from'../../../errors.js';export{readableFields,writableData,fieldColumn}from'./sql.js';function O(L,E){L=L-0x11c;const c=Z();let t=c[L];return t;}const validateInputData=({resource:L,data:E,update:update=![]})=>{const e=O;for(const [c,t]of Object['entries'](L['fields'])){if(t['required']&&t['writable']!==![]&&(E[c]===undefined||E[c]===null)&&!update)throw new ValidationError(e(0x11c)+c);if(t[e(0x11d)]&&t[e(0x11e)]!==![]&&Object['hasOwn'](E,c)&&(E[c]===undefined||E[c]===null)&&update)throw new ValidationError(e(0x11c)+c);if(t[e(0x11f)]&&typeof E[c]===e(0x120)&&E[c]['length']<t['minLength'])throw new ValidationError('minLength\x20not\x20met:\x20'+c);if(t['maxLength']&&typeof E[c]===e(0x120)&&E[c]['length']>t['maxLength'])throw new ValidationError('maxLength\x20exceeded:\x20'+c);if(t['minimum']&&typeof E[c]==='number'&&E[c]<t[e(0x121)])throw new ValidationError(c+e(0x122)+t[e(0x121)]);if(t['maximum']&&typeof E[c]===e(0x123)&&E[c]>t['maximum'])throw new ValidationError(c+'\x20should\x20be\x20<=\x20'+t[e(0x124)]);if(t[e(0x125)]&&E[c]&&!t['enum']['includes'](E[c]))throw new ValidationError(c+e(0x126)+t['enum']['join'](',\x20')+')');if(t['pattern']&&typeof E[c]==='string'&&!new RegExp(t[e(0x127)])['test'](E[c]))throw new ValidationError(c+e(0x128)+t['pattern']+')');}};export{validateInputData};function Z(){const B=['Required\x20field:\x20','required','writable','minLength','string','minimum','\x20should\x20be\x20>=\x20','number','maximum','enum','\x20should\x20be\x20one\x20of\x20(','pattern','\x20should\x20match\x20regular\x20expression\x20('];Z=function(){return B;};return Z();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{fieldColumn,qi}from'./sql.js';import{ValidationError}from'../../../errors.js';import{autoIndex}from'./auto-index.js';const filterOperators=new Set(['eq','ne','gt','gte','lt','lte','in','nin','like','ilike','null']);export function parseFilterQuery(L){const x=O,E={...isRecord(L[x(0xf3)])?L['filter']:{}};for(const [c,t]of Object['entries'](L)){const e=/^filter\[([^\]]+)\](?:\[([^\]]+)\])?$/['exec'](c);if(!e)continue;const [,B,g]=e;if(!B)continue;if(!g){E[B]=t;continue;}if(!filterOperators['has'](g))throw new ValidationError('Unsupported\x20filter\x20operator:\x20'+g);const r=isRecord(E[B])?E[B]:{};r[g]=(g==='in'||g==='nin')&&typeof t==='string'?t['split'](','):t,E[B]=r;}return Object['keys'](E)['length']?E:undefined;}function O(L,E){L=L-0xf3;const c=Z();let t=c[L];return t;}export function buildFilters(L,E,c=0x1,t){const W=O,e=[],B=[];for(const [g,r]of Object['entries'](E??{})){const X=L[W(0xf4)][g];if(!X||X[W(0xf3)]!==!![]&&X['filterable']!==!![])throw new ValidationError(W(0xf5)+g);const j=qi(fieldColumn(L,g)),F=isRecord(r)?r:{'eq':r};for(const [I,T]of Object['entries'](F)){if(!filterOperators['has'](I))throw new ValidationError('Unsupported\x20filter\x20operator:\x20'+I);if((I==='like'||I===W(0xf6))&&X['type']!=='string'&&X['type']!=='text')throw new ValidationError('Operator\x20'+I+'\x20requires\x20a\x20text\x20field:\x20'+g);t&&autoIndex(L['table'],fieldColumn(L,g),indexTypeFor(X[W(0xf7)],I),t);if(I==='null'){e[W(0xf8)](j+'\x20IS\x20'+(isTruthy(T)?'':W(0xf9))+W(0xfa));continue;}if(I==='in'||I===W(0xfb)){const G=Array['isArray'](T)?T:[T];if(G['length']===0x0){e['push'](I==='in'?'FALSE':'TRUE');continue;}B['push'](G),e[W(0xf8)](j+'\x20'+(I==='in'?'=\x20ANY':W(0xfc))+'($'+(c+B['length']-0x1)+')');continue;}const f={'eq':'=','ne':'<>','gt':'>','gte':'>=','lt':'<','lte':'<=','like':W(0xfd)},A='$'+(c+B['length']);if(I===W(0xfd)){B['push'](T+'%'),e[W(0xf8)]('lower('+j+')\x20like\x20lower('+A+')');continue;}B['push'](T),e['push'](j+'\x20'+f[I]+'\x20'+A);}}return{'sql':e['length']?'\x20WHERE\x20'+e['join']('\x20AND\x20'):'','values':B};}function isRecord(L){const q=O;return typeof L===q(0xfe)&&L!==null&&!Array['isArray'](L);}function isTruthy(L){const y=O;return L===!![]||L===y(0xff)||L==='1'||L===0x1;}function Z(){const Y=['filter','fields','Field\x20is\x20not\x20filterable:\x20','ilike','type','push','NOT\x20','NULL','nin','<>\x20ALL','like','object','true','btree'];Z=function(){return Y;};return Z();}function indexTypeFor(L,E){const p=O;if(E===p(0xfd)||E===p(0xf6))return'text';if(L==='geom'||L==='geometry')return'gist';return p(0x100);}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ForbiddenError}from'../../../errors.js';function
|
|
1
|
+
function O(L,E){L=L-0x64;const c=Z();let t=c[L];return t;}import{ForbiddenError}from'../../../errors.js';function Z(){const g=['access','permission','includes'];Z=function(){return g;};return Z();}import{getContext}from'../../../index.js';export function assertOperation(L,E,c){const B=O,t=getContext()['config'];if(t['debug'])return;if(!L['operations']['includes'](E))throw new ForbiddenError(L['name']+'.'+E+'\x20is\x20disabled');if(L['access']!=='public'&&c===undefined)throw new ForbiddenError('Authentication\x20required');if(L[B(0x64)]==='admin'&&c?.['type']!=='admin')throw new ForbiddenError('Admin\x20access\x20required');if(c?.['type']!=='admin'){const e=(L[B(0x65)]??L['name'])+':'+E;if(!c?.['permissions']?.[B(0x66)](e))throw new ForbiddenError('Missing\x20permission:\x20'+e);}}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Provides Resource helpers for sort handling.
|
|
3
3
|
*/
|
|
4
|
-
import type { ResourceContract } from
|
|
4
|
+
import type { ResourceContract } from "../resource.types.js";
|
|
5
5
|
export declare function buildSort(resource: ResourceContract, sort?: string[]): string;
|
|
6
6
|
//# sourceMappingURL=sort.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sort.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/utils/sort.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAG7D,wBAAgB,SAAS,CAAC,QAAQ,EAAE,gBAAgB,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"sort.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/utils/sort.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAG7D,wBAAgB,SAAS,CAAC,QAAQ,EAAE,gBAAgB,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,UAcpE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function O(L,E){L=L-0x185;const c=Z();let t=c[L];return t;}import{fieldColumn,qi}from'./sql.js';function Z(){const j=['length','string','map','slice','sortable','DESC','ASC','join'];Z=function(){return j;};return Z();}import{ValidationError}from'../../../errors.js';export function buildSort(L,E){const r=O;if(!E?.[r(0x185)])return'';typeof E===r(0x186)&&(E=[E]);const c=E[r(0x187)](t=>{const X=r,e=t['startsWith']('-'),B=e?t[X(0x188)](0x1):t,g=L['fields'][B];if(!g||g[X(0x189)]!==!![])throw new ValidationError('Field\x20is\x20not\x20sortable:\x20'+B);return qi(fieldColumn(L,B))+'\x20'+(e?X(0x18a):X(0x18b));});return'\x20ORDER\x20BY\x20'+c[r(0x18c)](',\x20');}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{ValidationError}from'../../../errors.js';export const quoteIdentifier=L=>'\x22'+L['replace'](/"/g,'\x22\x22')+'\x22';export const quoteTable=L=>L['split']('.')['map'](quoteIdentifier)['join']('.');export function fieldColumn(L,E){const g=O;if(E===L['key'])return L[g(0xed)];const c=L['fields'][E];if(!c)throw new ValidationError(g(0xee)+E);return c['column']??E;}export function readableFields(L,E){const r=O,c=Object[r(0xef)](L['fields'])[r(0xf0)](([,t])=>t['read']!==![]&&t['readable']!==![]&&(E?(t['scope']??'all')===E:!![]))[r(0xf1)](([t,e])=>quoteIdentifier(e[r(0xf2)]??t)+r(0xf3)+quoteIdentifier(t));return!L['fields'][L[r(0xed)]]&&c[r(0xf4)](quoteIdentifier(L[r(0xed)])),c;}function O(L,E){L=L-0xed;const c=Z();let t=c[L];return t;}export function writableData(L,E){const X=O,c=[];for(const [t,e]of Object[X(0xef)](E)){const B=L['fields'][t];if(!B||B['write']===![]||B[X(0xf5)]===![])throw new ValidationError('Field\x20is\x20not\x20writable:\x20'+t);if((B[X(0xf6)]??B[X(0xf5)])!==!![])continue;if(B['type']==='date'&&!E[t])continue;c['push']([B['column']??t,e]);}return c;}export const qi=quoteIdentifier;export const qt=quoteTable;function Z(){const j=['key','Unknown\x20field:\x20','entries','filter','map','column','\x20AS\x20','unshift','writable','write'];Z=function(){return j;};return Z();}
|
package/dist/shared/getIP.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const getIP=L=>(L['headers']?.['x-real-ip']||L['headers']?.['x-forwarded-for']||L['ip']||L['connection']?.['remoteAddress']||'')['split'](':')['pop']();export default getIP;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
CREATE SCHEMA IF NOT EXISTS admin;
|
|
2
|
-
|
|
3
|
-
DO $$
|
|
4
|
-
BEGIN
|
|
5
|
-
IF to_regclass('crm.notes') IS NOT NULL
|
|
6
|
-
AND to_regclass('admin.notes') IS NULL THEN
|
|
7
|
-
ALTER TABLE crm.notes SET SCHEMA admin;
|
|
8
|
-
END IF;
|
|
9
|
-
|
|
10
|
-
IF to_regclass('crm.files') IS NOT NULL
|
|
11
|
-
AND to_regclass('admin.files') IS NULL THEN
|
|
12
|
-
ALTER TABLE crm.files SET SCHEMA admin;
|
|
13
|
-
END IF;
|
|
14
|
-
END
|
|
15
|
-
$$;
|
|
16
|
-
|
|
17
|
-
ALTER INDEX IF EXISTS crm_notes_resource_idx RENAME TO admin_notes_resource_idx;
|
|
1
|
+
CREATE SCHEMA IF NOT EXISTS admin;
|
|
2
|
+
|
|
3
|
+
DO $$
|
|
4
|
+
BEGIN
|
|
5
|
+
IF to_regclass('crm.notes') IS NOT NULL
|
|
6
|
+
AND to_regclass('admin.notes') IS NULL THEN
|
|
7
|
+
ALTER TABLE crm.notes SET SCHEMA admin;
|
|
8
|
+
END IF;
|
|
9
|
+
|
|
10
|
+
IF to_regclass('crm.files') IS NOT NULL
|
|
11
|
+
AND to_regclass('admin.files') IS NULL THEN
|
|
12
|
+
ALTER TABLE crm.files SET SCHEMA admin;
|
|
13
|
+
END IF;
|
|
14
|
+
END
|
|
15
|
+
$$;
|
|
16
|
+
|
|
17
|
+
ALTER INDEX IF EXISTS crm_notes_resource_idx RENAME TO admin_notes_resource_idx;
|
|
18
18
|
ALTER INDEX IF EXISTS crm_notes_uid_idx RENAME TO admin_notes_uid_idx;
|