@stacksjs/orm 0.75.544 → 0.75.551
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.d.ts
CHANGED
|
@@ -109,7 +109,9 @@ export declare const EmailWebhookEvent: typeof import('./models/EmailWebhookEven
|
|
|
109
109
|
export declare const ErrorModel: typeof import('./models/Error').default;
|
|
110
110
|
export declare const GiftCard: typeof import('./models/commerce/GiftCard').default;
|
|
111
111
|
export declare const Label: typeof import('./models/Label').default;
|
|
112
|
+
export declare const LicenseActivation: typeof import('./models/commerce/LicenseActivation').default;
|
|
112
113
|
export declare const LicenseKey: typeof import('./models/commerce/LicenseKey').default;
|
|
114
|
+
export declare const LicenseSeat: typeof import('./models/commerce/LicenseSeat').default;
|
|
113
115
|
export declare const Log: typeof import('./models/Log').default;
|
|
114
116
|
export declare const LoyaltyPoint: typeof import('./models/commerce/LoyaltyPoint').default;
|
|
115
117
|
export declare const LoyaltyReward: typeof import('./models/commerce/LoyaltyReward').default;
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"@stacksjs/validation/runtime";import{isCompiledBinary}from"@stacksjs/path";export*from"./utils/prunable";export{collectEncryptedAttributes,decryptValue,encryptValue,isEncrypted}from"./utils/encrypted";export{setAuditUser,createAuditMethods}from"./traits/audit";export{createCommentableMethods}from"./traits/commentable";export{createTaggableMethods}from"./traits/taggable";export{createCategorizableMethods}from"./traits/categorizable";export{createLikeableMethods}from"./traits/likeable";export{BILLABLE_INSTANCE_METHODS,isBillable,SubscriptionNotOwnedError}from"./traits/billable";export{filterFillable,getWritableFields,isUniqueViolation,mapWriteError,toSnakeCaseKeys}from"./auto-crud";export{customerOwnership,parentOwnership,selfOwnership,siteOwnership,teamMembershipOwnership}from"./ownership";export*from"./batch-loader";export*from"./db";export*from"./subquery";export*from"./transaction";export*from"./locked-row";export*from"./row-token";export*from"./gdpr";export*from"./model-types";export*from"./types";export*from"@stacksjs/model-meta";export*from"./define-model";export*from"./extend-model";export{buildDatabaseSchema,renderDatabaseTypeFile}from"./generate-database-schema";export{isCursorPaginator,isPaginator,isSimplePaginator,toCursorPaginator,toPaginator,toSimplePaginator}from"@stacksjs/pagination";export{enrichPaginatorUrls,parseCursor,resolveCursorArgs,resolvePageArgs}from"./paginator-request";async function importDefault(modulePath){for(let attempt=0;;attempt++){const mod=await import(modulePath);try{return mod.default}catch(err){if(attempt<5&&err instanceof ReferenceError&&/before initialization/.test(err.message)){await new Promise((resolve)=>setTimeout(resolve,0));continue}throw err}}}let announcedCompiledSkip=false;async function loadUserlandModel(modelName,subdirs=[""]){if(isCompiledBinary()){if(!announcedCompiledSkip){announcedCompiledSkip=true;console.debug("[orm] running from a compiled binary, so framework default models are not probed on disk; models this app uses are bundled.")}return null}const{path}=await import("@stacksjs/path");const userPath=path.userModelsPath(`${modelName}.ts`);try{if(await Bun.file(userPath).exists()){return await importDefault(userPath)}}catch(err){console.error(`[orm] Failed to import userland model ${modelName} from ${userPath} - falling back to framework default. Reason:`,err)}for(const sub of subdirs){const prefix=sub?`${sub}/`:"";const defaultPath=path.frameworkPath(`defaults/app/Models/${prefix}${modelName}.ts`);try{if(await Bun.file(defaultPath).exists()){return await importDefault(defaultPath)}}catch(err){console.error(`[orm] Failed to import framework default model ${modelName} from ${defaultPath} - trying next subdir. Reason:`,err)}}return null}const _loaded={};let _modelsSettled=false;const QUERY_ENTRYPOINTS=new Set(["where","orWhere","whereIn","whereNotIn","whereNull","whereNotNull","whereLike","whereBetween","whereNotBetween","orderBy","orderByDesc","latest","oldest","limit","take","skip","select","find","findOrFail","findMany","first","firstOrFail","all","get","paginate","count","sum","avg","min","max","create","createMany","firstOrCreate","updateOrCreate","save","update","updateMany","delete","destroy","remove","truncate"]);function featureGateFor(name){return FRAMEWORK_MODEL_MANIFEST.find(([model])=>model===name)?.[2]}export function frameworkModelFeature(name){return FRAMEWORK_MODEL_MANIFEST.find(([model])=>model===name)?.[2]}export class ModelUnavailableError extends Error{model;feature;name="ModelUnavailableError";constructor(model,feature){super(`Model "${model}" is not available in this process. ${feature?`The '${feature}' feature is off, so this model was never loaded - set \`enabled: true\` in config/${feature}.ts to use it.`:`No model file for it was found under app/Models or the framework defaults.`}`);this.model=model;this.feature=feature}}function unavailableModel(name){return new ModelUnavailableError(name,featureGateFor(name))}let _readyResolve=()=>{};export const ormReady=new Promise((resolve)=>{_readyResolve=resolve});function lazyModel(name){return new Proxy(function _modelStub(){},{get(_target,prop){if(prop==="then")return;const m=_loaded[name];if(m==null){if(_modelsSettled&&typeof prop==="string"&&QUERY_ENTRYPOINTS.has(prop))throw unavailableModel(name);return}const value=m[prop];return typeof value==="function"?value.bind(m):value},set(_target,prop,value){const m=_loaded[name];if(m==null)return false;m[prop]=value;return true},has(_target,prop){const m=_loaded[name];return m==null?false:(prop in m)},apply(_target,thisArg,args){const m=_loaded[name];if(m==null||typeof m!=="function")return;return m.apply(thisArg,args)}})}export const User=lazyModel("User");export const Job=lazyModel("Job");export const QueueWorker=lazyModel("QueueWorker");export const FailedJob=lazyModel("FailedJob");const FRAMEWORK_MODEL_MANIFEST=[["QueueWorker",[""],"queue"],["Referral",[""],"auth"],["ReferralCode",[""],"auth"],["Team",[""],"auth"],["TeamInvitation",[""],"auth"],["TeamMember",[""],"auth"],["SocialAccount",[""],"auth"],["Subscriber",[""],"auth"],["SubscriberEmail",[""],"auth"],["Subscription",[""],"auth"],["Categorizable",["Content"],"cms"],["Post",["Content"],"cms"],["Page",["Content"],"cms"],["PageRevision",["Content"],"cms"],["Redirect",["Content"],"cms"],["Menu",["Content"],"cms"],["MenuItem",["Content"],"cms"],["Author",["Content"],"cms"],["Comment",[""],"cms"],["Tag",[""],"cms"],["Site",[""],"auth"],["SiteDomain",[""],"auth"],["MagicLinkToken",[""],"auth"],["SmsOptOut",[""],"auth"],["GdprRequest",[""],"auth"],["Form",["Forms"],"forms"],["FormField",["Forms"],"forms"],["FormSubmission",["Forms"],"forms"],["Activity",[""],"dashboard"],["Board",[""],"dashboard"],["BoardColumn",[""],"dashboard"],["Card",[""],"dashboard"],["CardAttachment",[""],"dashboard"],["CardComment",[""],"dashboard"],["Deployment",[""],"dashboard"],["FeedbackToken",[""],"dashboard"],["Label",[""],"dashboard"],["Release",[""],"dashboard"],["Notification",[""],"dashboard"],["NotificationDelivery",[""],"dashboard"],["PersonalAccessToken",[""],"dashboard"],["MailPreference",[""],"dashboard"],["Log",[""],"dashboard"],["Request",[""],"dashboard"],["AnalyticsEvent",[""],"dashboard"],["QueryLog",[""],"dashboard"],["StorageItem",[""],"dashboard"],["StorageItemTask",[""],"dashboard"],["Error",[""],"monitoring"],["Websocket",["realtime"],"realtime"],["Campaign",[""],"marketing"],["CampaignSend",[""],"marketing"],["EmailList",[""],"marketing"],["EmailListSubscriber",[""],"marketing"],["EmailIdempotency",[""],"marketing"],["EmailSuppression",[""],"marketing"],["EmailWebhookEvent",[""],"marketing"],["SocialPost",[""],"marketing"],["Automation",[""],"marketing"],["AutomationRun",[""],"marketing"],["CampaignVariant",[""],"marketing"],["CommunicationSuppression",[""],"marketing"],["ConsentEvent",[""],"marketing"],["SenderDomain",[""],"marketing"],["UsageEvent",[""],"marketing"],["PaymentMethod",[""],"commerce"],["PaymentProduct",[""],"commerce"],["PaymentTransaction",[""],"commerce"],["Order",["commerce"],"commerce"],["OrderIdempotency",["commerce"],"commerce"],["OrderItem",["commerce"],"commerce"],["Cart",["commerce"],"commerce"],["CartItem",["commerce"],"commerce"],["Customer",["commerce"],"commerce"],["Product",["commerce"],"commerce"],["ProductVariant",["commerce"],"commerce"],["ProductUnit",["commerce"],"commerce"],["Manufacturer",["commerce"],"commerce"],["Category",["commerce"],"commerce"],["Coupon",["commerce"],"commerce"],["GiftCard",["commerce"],"commerce"],["LicenseKey",["commerce"],"commerce"],["Review",["commerce"],"commerce"],["Receipt",["commerce"],"commerce"],["PrintDevice",["commerce"],"commerce"],["ShippingMethod",["commerce"],"commerce"],["ShippingRate",["commerce"],"commerce"],["ShippingZone",["commerce"],"commerce"],["DeliveryRoute",["commerce"],"commerce"],["DeliveryStop",["commerce"],"commerce"],["DigitalDelivery",["commerce"],"commerce"],["Courier",["commerce"],"commerce"],["CourierPing",["commerce"],"commerce"],["TaxRate",["commerce"],"commerce"],["WaitlistProduct",["commerce"],"commerce"],["WaitlistRestaurant",["commerce"],"commerce"],["Auction",["commerce"],"commerce"],["AuctionItem",["commerce"],"commerce"],["Bid",["commerce"],"commerce"],["Pledge",["commerce"],"commerce"],["LoyaltyPoint",["commerce"],"commerce"],["LoyaltyReward",["commerce"],"commerce"],["Payment",["commerce"],"commerce"],["PaymentWebhookEvent",["commerce"],"commerce"],["Transaction",["commerce"],"commerce"]];queueMicrotask(async()=>{try{const{feature}=await import("@stacksjs/config");const userModel=await loadUserlandModel("User");if(userModel)_loaded.User=userModel;if(feature("queue")){const job=await loadUserlandModel("Job");if(job)_loaded.Job=job;const failedJob=await loadUserlandModel("FailedJob");if(failedJob)_loaded.FailedJob=failedJob}for(const[name,subdirs,featureFlag]of FRAMEWORK_MODEL_MANIFEST){if(!feature(featureFlag))continue;const M=await loadUserlandModel(name,subdirs);if(M)_loaded[name]=M}}catch(err){console.error("[orm] deferred model load failed:",err)}finally{_modelsSettled=true;_readyResolve()}});export const Activity=lazyModel("Activity");export const AnalyticsEvent=lazyModel("AnalyticsEvent");export const Automation=lazyModel("Automation");export const AutomationRun=lazyModel("AutomationRun");export const Auction=lazyModel("Auction");export const CampaignVariant=lazyModel("CampaignVariant");export const CommunicationSuppression=lazyModel("CommunicationSuppression");export const ConsentEvent=lazyModel("ConsentEvent");export const SenderDomain=lazyModel("SenderDomain");export const UsageEvent=lazyModel("UsageEvent");export const AuctionItem=lazyModel("AuctionItem");export const Author=lazyModel("Author");export const Bid=lazyModel("Bid");export const Board=lazyModel("Board");export const BoardColumn=lazyModel("BoardColumn");export const Campaign=lazyModel("Campaign");export const Card=lazyModel("Card");export const CardAttachment=lazyModel("CardAttachment");export const CardComment=lazyModel("CardComment");export const Cart=lazyModel("Cart");export const CartItem=lazyModel("CartItem");export const Category=lazyModel("Category");export const Comment=lazyModel("Comment");export const Coupon=lazyModel("Coupon");export const Customer=lazyModel("Customer");export const DeliveryRoute=lazyModel("DeliveryRoute");export const DeliveryStop=lazyModel("DeliveryStop");export const Deployment=lazyModel("Deployment");export const FeedbackToken=lazyModel("FeedbackToken");export const DigitalDelivery=lazyModel("DigitalDelivery");export const Courier=lazyModel("Courier");export const CourierPing=lazyModel("CourierPing");export const CampaignSend=lazyModel("CampaignSend");export const EmailList=lazyModel("EmailList");export const EmailListSubscriber=lazyModel("EmailListSubscriber");export const Form=lazyModel("Form");export const FormField=lazyModel("FormField");export const FormSubmission=lazyModel("FormSubmission");export const MagicLinkToken=lazyModel("MagicLinkToken");export const Menu=lazyModel("Menu");export const MenuItem=lazyModel("MenuItem");export const PageRevision=lazyModel("PageRevision");export const Pledge=lazyModel("Pledge");export const Redirect=lazyModel("Redirect");export const Site=lazyModel("Site");export const SiteDomain=lazyModel("SiteDomain");export const SmsOptOut=lazyModel("SmsOptOut");export const GdprRequest=lazyModel("GdprRequest");export const StorageItem=lazyModel("StorageItem");export const StorageItemTask=lazyModel("StorageItemTask");export const EmailIdempotency=lazyModel("EmailIdempotency");export const EmailSuppression=lazyModel("EmailSuppression");export const EmailWebhookEvent=lazyModel("EmailWebhookEvent");export const ErrorModel=lazyModel("Error");export const GiftCard=lazyModel("GiftCard");export const Label=lazyModel("Label");export const LicenseKey=lazyModel("LicenseKey");export const Log=lazyModel("Log");export const LoyaltyPoint=lazyModel("LoyaltyPoint");export const LoyaltyReward=lazyModel("LoyaltyReward");export const MailPreference=lazyModel("MailPreference");export const Manufacturer=lazyModel("Manufacturer");export const Notification=lazyModel("Notification");export const NotificationDelivery=lazyModel("NotificationDelivery");export const Order=lazyModel("Order");export const OrderIdempotency=lazyModel("OrderIdempotency");export const PersonalAccessToken=lazyModel("PersonalAccessToken");export const OrderItem=lazyModel("OrderItem");export const Page=lazyModel("Page");export const Payment=lazyModel("Payment");export const PaymentWebhookEvent=lazyModel("PaymentWebhookEvent");export const PaymentMethod=lazyModel("PaymentMethod");export const PaymentProduct=lazyModel("PaymentProduct");export const PaymentTransaction=lazyModel("PaymentTransaction");export const Post=lazyModel("Post");export const Categorizable=lazyModel("Categorizable");export const PrintDevice=lazyModel("PrintDevice");export const Product=lazyModel("Product");export const ProductUnit=lazyModel("ProductUnit");export const ProductVariant=lazyModel("ProductVariant");export const QueryLog=lazyModel("QueryLog");export const Receipt=lazyModel("Receipt");export const Referral=lazyModel("Referral");export const ReferralCode=lazyModel("ReferralCode");export const Release=lazyModel("Release");export const Request=lazyModel("Request");export const Review=lazyModel("Review");export const ShippingMethod=lazyModel("ShippingMethod");export const ShippingRate=lazyModel("ShippingRate");export const ShippingZone=lazyModel("ShippingZone");export const SocialPost=lazyModel("SocialPost");export const SocialAccount=lazyModel("SocialAccount");export const Subscriber=lazyModel("Subscriber");export const SubscriberEmail=lazyModel("SubscriberEmail");export const Subscription=lazyModel("Subscription");export const Tag=lazyModel("Tag");export const TaxRate=lazyModel("TaxRate");export const Team=lazyModel("Team");export const TeamInvitation=lazyModel("TeamInvitation");export const TeamMember=lazyModel("TeamMember");export const Transaction=lazyModel("Transaction");export const WaitlistProduct=lazyModel("WaitlistProduct");export const WaitlistRestaurant=lazyModel("WaitlistRestaurant");export const Websocket=lazyModel("Websocket");const _allExports={User,Job,FailedJob,QueueWorker,Activity,AnalyticsEvent,Automation,AutomationRun,Auction,AuctionItem,Author,Bid,Board,BoardColumn,Campaign,CampaignSend,CampaignVariant,Card,CardComment,Cart,CartItem,Categorizable,Category,Comment,Coupon,Customer,CommunicationSuppression,ConsentEvent,DeliveryRoute,DeliveryStop,Deployment,DigitalDelivery,Courier,CourierPing,EmailList,EmailListSubscriber,EmailIdempotency,EmailSuppression,EmailWebhookEvent,ErrorModel,Form,FormField,FormSubmission,GdprRequest,GiftCard,Label,LicenseKey,Log,LoyaltyPoint,LoyaltyReward,MailPreference,Manufacturer,Notification,MagicLinkToken,Menu,MenuItem,NotificationDelivery,Order,OrderIdempotency,OrderItem,Page,PageRevision,Payment,PaymentMethod,PaymentProduct,PaymentTransaction,PaymentWebhookEvent,Pledge,Post,PrintDevice,Product,ProductUnit,ProductVariant,QueryLog,Receipt,Release,Request,Review,ShippingMethod,Redirect,SenderDomain,ShippingRate,ShippingZone,Site,SiteDomain,SmsOptOut,SocialAccount,SocialPost,Subscriber,SubscriberEmail,Subscription,Tag,TaxRate,Team,TeamInvitation,TeamMember,Transaction,UsageEvent,WaitlistProduct,WaitlistRestaurant,Websocket};const g=globalThis;for(const[name,M]of Object.entries(_allExports)){if(M&&g[name]===undefined)g[name]=M}export const modelGlobalNames=Object.keys(_allExports);async function _safeAll(M){if(!M)return[];try{if(typeof M.all==="function"){const rows=await M.all();return Array.isArray(rows)?rows:[]}if(typeof M.get==="function"){const rows=await M.get();return Array.isArray(rows)?rows:[]}}catch{}return[]}function _safeGet(row,key,fallback=""){if(!row)return fallback;try{if(typeof row.get==="function"){const v=row.get(key);if(v!==undefined&&v!==null)return v}}catch{}const direct=row?.[key];return direct!==undefined&&direct!==null?direct:fallback}if(g.safeAll===undefined)g.safeAll=_safeAll;if(g.safeGet===undefined)g.safeGet=_safeGet;export*from"./messaging";
|
|
1
|
+
import"@stacksjs/validation/runtime";import{isCompiledBinary}from"@stacksjs/path";export*from"./utils/prunable";export{collectEncryptedAttributes,decryptValue,encryptValue,isEncrypted}from"./utils/encrypted";export{setAuditUser,createAuditMethods}from"./traits/audit";export{createCommentableMethods}from"./traits/commentable";export{createTaggableMethods}from"./traits/taggable";export{createCategorizableMethods}from"./traits/categorizable";export{createLikeableMethods}from"./traits/likeable";export{BILLABLE_INSTANCE_METHODS,isBillable,SubscriptionNotOwnedError}from"./traits/billable";export{filterFillable,getWritableFields,isUniqueViolation,mapWriteError,toSnakeCaseKeys}from"./auto-crud";export{customerOwnership,parentOwnership,selfOwnership,siteOwnership,teamMembershipOwnership}from"./ownership";export*from"./batch-loader";export*from"./db";export*from"./subquery";export*from"./transaction";export*from"./locked-row";export*from"./row-token";export*from"./gdpr";export*from"./model-types";export*from"./types";export*from"@stacksjs/model-meta";export*from"./define-model";export*from"./extend-model";export{buildDatabaseSchema,renderDatabaseTypeFile}from"./generate-database-schema";export{isCursorPaginator,isPaginator,isSimplePaginator,toCursorPaginator,toPaginator,toSimplePaginator}from"@stacksjs/pagination";export{enrichPaginatorUrls,parseCursor,resolveCursorArgs,resolvePageArgs}from"./paginator-request";async function importDefault(modulePath){for(let attempt=0;;attempt++){const mod=await import(modulePath);try{return mod.default}catch(err){if(attempt<5&&err instanceof ReferenceError&&/before initialization/.test(err.message)){await new Promise((resolve)=>setTimeout(resolve,0));continue}throw err}}}let announcedCompiledSkip=false;async function loadUserlandModel(modelName,subdirs=[""]){if(isCompiledBinary()){if(!announcedCompiledSkip){announcedCompiledSkip=true;console.debug("[orm] running from a compiled binary, so framework default models are not probed on disk; models this app uses are bundled.")}return null}const{path}=await import("@stacksjs/path");const userPath=path.userModelsPath(`${modelName}.ts`);try{if(await Bun.file(userPath).exists()){return await importDefault(userPath)}}catch(err){console.error(`[orm] Failed to import userland model ${modelName} from ${userPath} - falling back to framework default. Reason:`,err)}for(const sub of subdirs){const prefix=sub?`${sub}/`:"";const defaultPath=path.frameworkPath(`defaults/app/Models/${prefix}${modelName}.ts`);try{if(await Bun.file(defaultPath).exists()){return await importDefault(defaultPath)}}catch(err){console.error(`[orm] Failed to import framework default model ${modelName} from ${defaultPath} - trying next subdir. Reason:`,err)}}return null}const _loaded={};let _modelsSettled=false;const QUERY_ENTRYPOINTS=new Set(["where","orWhere","whereIn","whereNotIn","whereNull","whereNotNull","whereLike","whereBetween","whereNotBetween","orderBy","orderByDesc","latest","oldest","limit","take","skip","select","find","findOrFail","findMany","first","firstOrFail","all","get","paginate","count","sum","avg","min","max","create","createMany","firstOrCreate","updateOrCreate","save","update","updateMany","delete","destroy","remove","truncate"]);function featureGateFor(name){return FRAMEWORK_MODEL_MANIFEST.find(([model])=>model===name)?.[2]}export function frameworkModelFeature(name){return FRAMEWORK_MODEL_MANIFEST.find(([model])=>model===name)?.[2]}export class ModelUnavailableError extends Error{model;feature;name="ModelUnavailableError";constructor(model,feature){super(`Model "${model}" is not available in this process. ${feature?`The '${feature}' feature is off, so this model was never loaded - set \`enabled: true\` in config/${feature}.ts to use it.`:`No model file for it was found under app/Models or the framework defaults.`}`);this.model=model;this.feature=feature}}function unavailableModel(name){return new ModelUnavailableError(name,featureGateFor(name))}let _readyResolve=()=>{};export const ormReady=new Promise((resolve)=>{_readyResolve=resolve});function lazyModel(name){return new Proxy(function _modelStub(){},{get(_target,prop){if(prop==="then")return;const m=_loaded[name];if(m==null){if(_modelsSettled&&typeof prop==="string"&&QUERY_ENTRYPOINTS.has(prop))throw unavailableModel(name);return}const value=m[prop];return typeof value==="function"?value.bind(m):value},set(_target,prop,value){const m=_loaded[name];if(m==null)return false;m[prop]=value;return true},has(_target,prop){const m=_loaded[name];return m==null?false:(prop in m)},apply(_target,thisArg,args){const m=_loaded[name];if(m==null||typeof m!=="function")return;return m.apply(thisArg,args)}})}export const User=lazyModel("User");export const Job=lazyModel("Job");export const QueueWorker=lazyModel("QueueWorker");export const FailedJob=lazyModel("FailedJob");const FRAMEWORK_MODEL_MANIFEST=[["QueueWorker",[""],"queue"],["Referral",[""],"auth"],["ReferralCode",[""],"auth"],["Team",[""],"auth"],["TeamInvitation",[""],"auth"],["TeamMember",[""],"auth"],["SocialAccount",[""],"auth"],["Subscriber",[""],"auth"],["SubscriberEmail",[""],"auth"],["Subscription",[""],"auth"],["Categorizable",["Content"],"cms"],["Post",["Content"],"cms"],["Page",["Content"],"cms"],["PageRevision",["Content"],"cms"],["Redirect",["Content"],"cms"],["Menu",["Content"],"cms"],["MenuItem",["Content"],"cms"],["Author",["Content"],"cms"],["Comment",[""],"cms"],["Tag",[""],"cms"],["Site",[""],"auth"],["SiteDomain",[""],"auth"],["MagicLinkToken",[""],"auth"],["SmsOptOut",[""],"auth"],["GdprRequest",[""],"auth"],["Form",["Forms"],"forms"],["FormField",["Forms"],"forms"],["FormSubmission",["Forms"],"forms"],["Activity",[""],"dashboard"],["Board",[""],"dashboard"],["BoardColumn",[""],"dashboard"],["Card",[""],"dashboard"],["CardAttachment",[""],"dashboard"],["CardComment",[""],"dashboard"],["Deployment",[""],"dashboard"],["FeedbackToken",[""],"dashboard"],["Label",[""],"dashboard"],["Release",[""],"dashboard"],["Notification",[""],"dashboard"],["NotificationDelivery",[""],"dashboard"],["PersonalAccessToken",[""],"dashboard"],["MailPreference",[""],"dashboard"],["Log",[""],"dashboard"],["Request",[""],"dashboard"],["AnalyticsEvent",[""],"dashboard"],["QueryLog",[""],"dashboard"],["StorageItem",[""],"dashboard"],["StorageItemTask",[""],"dashboard"],["Error",[""],"monitoring"],["Websocket",["realtime"],"realtime"],["Campaign",[""],"marketing"],["CampaignSend",[""],"marketing"],["EmailList",[""],"marketing"],["EmailListSubscriber",[""],"marketing"],["EmailIdempotency",[""],"marketing"],["EmailSuppression",[""],"marketing"],["EmailWebhookEvent",[""],"marketing"],["SocialPost",[""],"marketing"],["Automation",[""],"marketing"],["AutomationRun",[""],"marketing"],["CampaignVariant",[""],"marketing"],["CommunicationSuppression",[""],"marketing"],["ConsentEvent",[""],"marketing"],["SenderDomain",[""],"marketing"],["UsageEvent",[""],"marketing"],["PaymentMethod",[""],"commerce"],["PaymentProduct",[""],"commerce"],["PaymentTransaction",[""],"commerce"],["Order",["commerce"],"commerce"],["OrderIdempotency",["commerce"],"commerce"],["OrderItem",["commerce"],"commerce"],["Cart",["commerce"],"commerce"],["CartItem",["commerce"],"commerce"],["Customer",["commerce"],"commerce"],["Product",["commerce"],"commerce"],["ProductVariant",["commerce"],"commerce"],["ProductUnit",["commerce"],"commerce"],["Manufacturer",["commerce"],"commerce"],["Category",["commerce"],"commerce"],["Coupon",["commerce"],"commerce"],["GiftCard",["commerce"],"commerce"],["LicenseKey",["commerce"],"commerce"],["LicenseActivation",["commerce"],"commerce"],["LicenseSeat",["commerce"],"commerce"],["Review",["commerce"],"commerce"],["Receipt",["commerce"],"commerce"],["PrintDevice",["commerce"],"commerce"],["ShippingMethod",["commerce"],"commerce"],["ShippingRate",["commerce"],"commerce"],["ShippingZone",["commerce"],"commerce"],["DeliveryRoute",["commerce"],"commerce"],["DeliveryStop",["commerce"],"commerce"],["DigitalDelivery",["commerce"],"commerce"],["Courier",["commerce"],"commerce"],["CourierPing",["commerce"],"commerce"],["TaxRate",["commerce"],"commerce"],["WaitlistProduct",["commerce"],"commerce"],["WaitlistRestaurant",["commerce"],"commerce"],["Auction",["commerce"],"commerce"],["AuctionItem",["commerce"],"commerce"],["Bid",["commerce"],"commerce"],["Pledge",["commerce"],"commerce"],["LoyaltyPoint",["commerce"],"commerce"],["LoyaltyReward",["commerce"],"commerce"],["Payment",["commerce"],"commerce"],["PaymentWebhookEvent",["commerce"],"commerce"],["Transaction",["commerce"],"commerce"]];queueMicrotask(async()=>{try{const{feature}=await import("@stacksjs/config");const userModel=await loadUserlandModel("User");if(userModel)_loaded.User=userModel;if(feature("queue")){const job=await loadUserlandModel("Job");if(job)_loaded.Job=job;const failedJob=await loadUserlandModel("FailedJob");if(failedJob)_loaded.FailedJob=failedJob}for(const[name,subdirs,featureFlag]of FRAMEWORK_MODEL_MANIFEST){if(!feature(featureFlag))continue;const M=await loadUserlandModel(name,subdirs);if(M)_loaded[name]=M}}catch(err){console.error("[orm] deferred model load failed:",err)}finally{_modelsSettled=true;_readyResolve()}});export const Activity=lazyModel("Activity");export const AnalyticsEvent=lazyModel("AnalyticsEvent");export const Automation=lazyModel("Automation");export const AutomationRun=lazyModel("AutomationRun");export const Auction=lazyModel("Auction");export const CampaignVariant=lazyModel("CampaignVariant");export const CommunicationSuppression=lazyModel("CommunicationSuppression");export const ConsentEvent=lazyModel("ConsentEvent");export const SenderDomain=lazyModel("SenderDomain");export const UsageEvent=lazyModel("UsageEvent");export const AuctionItem=lazyModel("AuctionItem");export const Author=lazyModel("Author");export const Bid=lazyModel("Bid");export const Board=lazyModel("Board");export const BoardColumn=lazyModel("BoardColumn");export const Campaign=lazyModel("Campaign");export const Card=lazyModel("Card");export const CardAttachment=lazyModel("CardAttachment");export const CardComment=lazyModel("CardComment");export const Cart=lazyModel("Cart");export const CartItem=lazyModel("CartItem");export const Category=lazyModel("Category");export const Comment=lazyModel("Comment");export const Coupon=lazyModel("Coupon");export const Customer=lazyModel("Customer");export const DeliveryRoute=lazyModel("DeliveryRoute");export const DeliveryStop=lazyModel("DeliveryStop");export const Deployment=lazyModel("Deployment");export const FeedbackToken=lazyModel("FeedbackToken");export const DigitalDelivery=lazyModel("DigitalDelivery");export const Courier=lazyModel("Courier");export const CourierPing=lazyModel("CourierPing");export const CampaignSend=lazyModel("CampaignSend");export const EmailList=lazyModel("EmailList");export const EmailListSubscriber=lazyModel("EmailListSubscriber");export const Form=lazyModel("Form");export const FormField=lazyModel("FormField");export const FormSubmission=lazyModel("FormSubmission");export const MagicLinkToken=lazyModel("MagicLinkToken");export const Menu=lazyModel("Menu");export const MenuItem=lazyModel("MenuItem");export const PageRevision=lazyModel("PageRevision");export const Pledge=lazyModel("Pledge");export const Redirect=lazyModel("Redirect");export const Site=lazyModel("Site");export const SiteDomain=lazyModel("SiteDomain");export const SmsOptOut=lazyModel("SmsOptOut");export const GdprRequest=lazyModel("GdprRequest");export const StorageItem=lazyModel("StorageItem");export const StorageItemTask=lazyModel("StorageItemTask");export const EmailIdempotency=lazyModel("EmailIdempotency");export const EmailSuppression=lazyModel("EmailSuppression");export const EmailWebhookEvent=lazyModel("EmailWebhookEvent");export const ErrorModel=lazyModel("Error");export const GiftCard=lazyModel("GiftCard");export const Label=lazyModel("Label");export const LicenseActivation=lazyModel("LicenseActivation");export const LicenseKey=lazyModel("LicenseKey");export const LicenseSeat=lazyModel("LicenseSeat");export const Log=lazyModel("Log");export const LoyaltyPoint=lazyModel("LoyaltyPoint");export const LoyaltyReward=lazyModel("LoyaltyReward");export const MailPreference=lazyModel("MailPreference");export const Manufacturer=lazyModel("Manufacturer");export const Notification=lazyModel("Notification");export const NotificationDelivery=lazyModel("NotificationDelivery");export const Order=lazyModel("Order");export const OrderIdempotency=lazyModel("OrderIdempotency");export const PersonalAccessToken=lazyModel("PersonalAccessToken");export const OrderItem=lazyModel("OrderItem");export const Page=lazyModel("Page");export const Payment=lazyModel("Payment");export const PaymentWebhookEvent=lazyModel("PaymentWebhookEvent");export const PaymentMethod=lazyModel("PaymentMethod");export const PaymentProduct=lazyModel("PaymentProduct");export const PaymentTransaction=lazyModel("PaymentTransaction");export const Post=lazyModel("Post");export const Categorizable=lazyModel("Categorizable");export const PrintDevice=lazyModel("PrintDevice");export const Product=lazyModel("Product");export const ProductUnit=lazyModel("ProductUnit");export const ProductVariant=lazyModel("ProductVariant");export const QueryLog=lazyModel("QueryLog");export const Receipt=lazyModel("Receipt");export const Referral=lazyModel("Referral");export const ReferralCode=lazyModel("ReferralCode");export const Release=lazyModel("Release");export const Request=lazyModel("Request");export const Review=lazyModel("Review");export const ShippingMethod=lazyModel("ShippingMethod");export const ShippingRate=lazyModel("ShippingRate");export const ShippingZone=lazyModel("ShippingZone");export const SocialPost=lazyModel("SocialPost");export const SocialAccount=lazyModel("SocialAccount");export const Subscriber=lazyModel("Subscriber");export const SubscriberEmail=lazyModel("SubscriberEmail");export const Subscription=lazyModel("Subscription");export const Tag=lazyModel("Tag");export const TaxRate=lazyModel("TaxRate");export const Team=lazyModel("Team");export const TeamInvitation=lazyModel("TeamInvitation");export const TeamMember=lazyModel("TeamMember");export const Transaction=lazyModel("Transaction");export const WaitlistProduct=lazyModel("WaitlistProduct");export const WaitlistRestaurant=lazyModel("WaitlistRestaurant");export const Websocket=lazyModel("Websocket");const _allExports={User,Job,FailedJob,QueueWorker,Activity,AnalyticsEvent,Automation,AutomationRun,Auction,AuctionItem,Author,Bid,Board,BoardColumn,Campaign,CampaignSend,CampaignVariant,Card,CardComment,Cart,CartItem,Categorizable,Category,Comment,Coupon,Customer,CommunicationSuppression,ConsentEvent,DeliveryRoute,DeliveryStop,Deployment,DigitalDelivery,Courier,CourierPing,EmailList,EmailListSubscriber,EmailIdempotency,EmailSuppression,EmailWebhookEvent,ErrorModel,Form,FormField,FormSubmission,GdprRequest,GiftCard,Label,LicenseActivation,LicenseKey,LicenseSeat,Log,LoyaltyPoint,LoyaltyReward,MailPreference,Manufacturer,Notification,MagicLinkToken,Menu,MenuItem,NotificationDelivery,Order,OrderIdempotency,OrderItem,Page,PageRevision,Payment,PaymentMethod,PaymentProduct,PaymentTransaction,PaymentWebhookEvent,Pledge,Post,PrintDevice,Product,ProductUnit,ProductVariant,QueryLog,Receipt,Release,Request,Review,ShippingMethod,Redirect,SenderDomain,ShippingRate,ShippingZone,Site,SiteDomain,SmsOptOut,SocialAccount,SocialPost,Subscriber,SubscriberEmail,Subscription,Tag,TaxRate,Team,TeamInvitation,TeamMember,Transaction,UsageEvent,WaitlistProduct,WaitlistRestaurant,Websocket};const g=globalThis;for(const[name,M]of Object.entries(_allExports)){if(M&&g[name]===undefined)g[name]=M}export const modelGlobalNames=Object.keys(_allExports);async function _safeAll(M){if(!M)return[];try{if(typeof M.all==="function"){const rows=await M.all();return Array.isArray(rows)?rows:[]}if(typeof M.get==="function"){const rows=await M.get();return Array.isArray(rows)?rows:[]}}catch{}return[]}function _safeGet(row,key,fallback=""){if(!row)return fallback;try{if(typeof row.get==="function"){const v=row.get(key);if(v!==undefined&&v!==null)return v}}catch{}const direct=row?.[key];return direct!==undefined&&direct!==null?direct:fallback}if(g.safeAll===undefined)g.safeAll=_safeAll;if(g.safeGet===undefined)g.safeGet=_safeGet;export*from"./messaging";
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { defineModel } from '@stacksjs/orm'
|
|
2
|
+
import { schema } from '@stacksjs/validation/runtime'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* One device using a license.
|
|
6
|
+
*
|
|
7
|
+
* A license allows `maxDevices` of these at a time (per seat, for a team
|
|
8
|
+
* license). The device is known only by the SHA-256 of an id the app chose,
|
|
9
|
+
* plus the name its owner sees when the limit is reached. Releasing a device
|
|
10
|
+
* sets `releasedAt` and frees its slot; activating it again clears it.
|
|
11
|
+
*/
|
|
12
|
+
export default defineModel({
|
|
13
|
+
name: 'LicenseActivation',
|
|
14
|
+
table: 'license_activations',
|
|
15
|
+
primaryKey: 'id',
|
|
16
|
+
autoIncrement: true,
|
|
17
|
+
|
|
18
|
+
indexes: [
|
|
19
|
+
{
|
|
20
|
+
name: 'license_activations_license_device_unique',
|
|
21
|
+
columns: ['license_key_id', 'device_hash'],
|
|
22
|
+
unique: true,
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
|
|
26
|
+
// Written by the license routes for a key holder, never for a signed-in caller.
|
|
27
|
+
ownership: false,
|
|
28
|
+
|
|
29
|
+
belongsTo: ['LicenseKey'],
|
|
30
|
+
|
|
31
|
+
traits: {
|
|
32
|
+
useTimestamps: true,
|
|
33
|
+
useSeeder: { count: 0 },
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
attributes: {
|
|
37
|
+
/** SHA-256 of the device id, hex. */
|
|
38
|
+
deviceHash: {
|
|
39
|
+
required: true,
|
|
40
|
+
fillable: true,
|
|
41
|
+
validation: {
|
|
42
|
+
rule: schema.string().required().max(64),
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
deviceName: {
|
|
46
|
+
fillable: true,
|
|
47
|
+
nullable: true,
|
|
48
|
+
validation: {
|
|
49
|
+
rule: schema.string().max(255),
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
platform: {
|
|
53
|
+
fillable: true,
|
|
54
|
+
nullable: true,
|
|
55
|
+
validation: {
|
|
56
|
+
rule: schema.string().max(32),
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
appVersion: {
|
|
60
|
+
fillable: true,
|
|
61
|
+
nullable: true,
|
|
62
|
+
validation: {
|
|
63
|
+
rule: schema.string().max(64),
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
/** The seat this device is activated under, for a team license. */
|
|
67
|
+
licenseSeatId: {
|
|
68
|
+
fillable: true,
|
|
69
|
+
nullable: true,
|
|
70
|
+
validation: {
|
|
71
|
+
rule: schema.number(),
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
firstSeenAt: {
|
|
75
|
+
required: true,
|
|
76
|
+
fillable: true,
|
|
77
|
+
validation: {
|
|
78
|
+
rule: schema.timestamp().required(),
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
lastSeenAt: {
|
|
82
|
+
required: true,
|
|
83
|
+
fillable: true,
|
|
84
|
+
validation: {
|
|
85
|
+
rule: schema.timestamp().required(),
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
releasedAt: {
|
|
89
|
+
fillable: true,
|
|
90
|
+
nullable: true,
|
|
91
|
+
validation: {
|
|
92
|
+
rule: schema.timestamp(),
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
|
|
97
|
+
dashboard: { enabled: false },
|
|
98
|
+
} as const)
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { customerOwnership, defineModel } from '@stacksjs/orm'
|
|
2
2
|
import { schema } from '@stacksjs/validation/runtime'
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* A software license: a key a customer was sold or handed, what it entitles
|
|
6
|
+
* them to, and where it stands.
|
|
7
|
+
*
|
|
8
|
+
* The same row serves two uses. As a deliverable it is a key attached to an
|
|
9
|
+
* order (the dashboard's license keys, `template`, `expiryDate`). As a license
|
|
10
|
+
* for an app (`@stacksjs/commerce` `licensing`) it also carries a `tier`, the
|
|
11
|
+
* last release it unlocks (`updatesUntil`, null for every release), how many
|
|
12
|
+
* devices and seats it covers, and the purchase it was issued for.
|
|
13
|
+
*/
|
|
4
14
|
export default defineModel({
|
|
5
15
|
name: 'LicenseKey',
|
|
6
16
|
table: 'license_keys',
|
|
@@ -16,10 +26,10 @@ export default defineModel({
|
|
|
16
26
|
useUuid: true,
|
|
17
27
|
useTimestamps: true,
|
|
18
28
|
useSearch: {
|
|
19
|
-
displayable: ['id', 'key', 'template', 'expiryDate', 'status'],
|
|
20
|
-
searchable: ['key'],
|
|
21
|
-
sortable: ['template', 'expiryDate', 'status', 'createdAt', 'updatedAt'],
|
|
22
|
-
filterable: ['status', 'template'],
|
|
29
|
+
displayable: ['id', 'key', 'template', 'tier', 'expiryDate', 'updatesUntil', 'status'],
|
|
30
|
+
searchable: ['key', 'email'],
|
|
31
|
+
sortable: ['template', 'tier', 'expiryDate', 'updatesUntil', 'status', 'createdAt', 'updatedAt'],
|
|
32
|
+
filterable: ['status', 'template', 'tier'],
|
|
23
33
|
},
|
|
24
34
|
|
|
25
35
|
useSeeder: {
|
|
@@ -34,7 +44,8 @@ export default defineModel({
|
|
|
34
44
|
observe: true,
|
|
35
45
|
},
|
|
36
46
|
|
|
37
|
-
belongsTo: ['Customer', 'Product', 'Order'],
|
|
47
|
+
belongsTo: ['Customer', 'Product', 'Order', 'Team'],
|
|
48
|
+
hasMany: ['LicenseActivation', 'LicenseSeat'],
|
|
38
49
|
|
|
39
50
|
attributes: {
|
|
40
51
|
key: {
|
|
@@ -62,11 +73,14 @@ export default defineModel({
|
|
|
62
73
|
factory: faker => faker.helpers.arrayElement(['Standard License', 'Premium License', 'Enterprise License']),
|
|
63
74
|
},
|
|
64
75
|
|
|
76
|
+
// Null for a license that never ends: standard and lifetime are owned
|
|
77
|
+
// outright, and only `updatesUntil` limits what a standard one unlocks.
|
|
65
78
|
expiryDate: {
|
|
66
79
|
order: 3,
|
|
67
80
|
fillable: true,
|
|
81
|
+
nullable: true,
|
|
68
82
|
validation: {
|
|
69
|
-
rule: schema.timestamp()
|
|
83
|
+
rule: schema.timestamp(),
|
|
70
84
|
message: {
|
|
71
85
|
timestamp: 'Expiry date must be a valid timestamp',
|
|
72
86
|
},
|
|
@@ -82,10 +96,138 @@ export default defineModel({
|
|
|
82
96
|
order: 4,
|
|
83
97
|
fillable: true,
|
|
84
98
|
validation: {
|
|
85
|
-
rule: schema.enum(['active', 'inactive', 'unassigned']),
|
|
99
|
+
rule: schema.enum(['active', 'inactive', 'unassigned', 'revoked', 'refunded']),
|
|
86
100
|
},
|
|
87
101
|
factory: faker => faker.helpers.arrayElement(['active', 'inactive', 'unassigned']),
|
|
88
102
|
},
|
|
103
|
+
|
|
104
|
+
/** What was bought: a year of updates, every update, or seats for a team. */
|
|
105
|
+
tier: {
|
|
106
|
+
default: 'standard',
|
|
107
|
+
order: 5,
|
|
108
|
+
fillable: true,
|
|
109
|
+
validation: {
|
|
110
|
+
rule: schema.enum(['standard', 'lifetime', 'team']),
|
|
111
|
+
},
|
|
112
|
+
factory: () => 'standard',
|
|
113
|
+
},
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* The last release date this license unlocks. Builds released on or before
|
|
117
|
+
* it stay unlocked for good; null unlocks every build.
|
|
118
|
+
*/
|
|
119
|
+
updatesUntil: {
|
|
120
|
+
order: 6,
|
|
121
|
+
fillable: true,
|
|
122
|
+
nullable: true,
|
|
123
|
+
validation: {
|
|
124
|
+
rule: schema.timestamp(),
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
|
|
128
|
+
/** Devices one holder may have active at once. */
|
|
129
|
+
maxDevices: {
|
|
130
|
+
default: 2,
|
|
131
|
+
order: 7,
|
|
132
|
+
fillable: true,
|
|
133
|
+
validation: {
|
|
134
|
+
rule: schema.number().min(1),
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
|
|
138
|
+
/** People a team license covers. One for a personal license. */
|
|
139
|
+
seats: {
|
|
140
|
+
default: 1,
|
|
141
|
+
order: 8,
|
|
142
|
+
fillable: true,
|
|
143
|
+
validation: {
|
|
144
|
+
rule: schema.number().min(1),
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
|
|
148
|
+
/** Where the key is sent, and the address a resend is asked for. */
|
|
149
|
+
email: {
|
|
150
|
+
order: 9,
|
|
151
|
+
fillable: true,
|
|
152
|
+
nullable: true,
|
|
153
|
+
personal: true,
|
|
154
|
+
validation: {
|
|
155
|
+
rule: schema.string().max(254),
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Your reference for the purchase this license was issued for, echoed by
|
|
161
|
+
* the payment provider's webhook. Unique, so a purchase issues one license
|
|
162
|
+
* however many times its events arrive.
|
|
163
|
+
*/
|
|
164
|
+
purchaseReference: {
|
|
165
|
+
order: 10,
|
|
166
|
+
fillable: true,
|
|
167
|
+
nullable: true,
|
|
168
|
+
unique: true,
|
|
169
|
+
validation: {
|
|
170
|
+
rule: schema.string().max(255),
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
|
|
174
|
+
/** The provider's id for the payment, which is what a refund names. */
|
|
175
|
+
paymentReference: {
|
|
176
|
+
order: 11,
|
|
177
|
+
fillable: true,
|
|
178
|
+
nullable: true,
|
|
179
|
+
validation: {
|
|
180
|
+
rule: schema.string().max(255),
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
|
|
184
|
+
/** The payment driver the purchase came through. */
|
|
185
|
+
provider: {
|
|
186
|
+
order: 12,
|
|
187
|
+
fillable: true,
|
|
188
|
+
nullable: true,
|
|
189
|
+
validation: {
|
|
190
|
+
rule: schema.string().max(64),
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
|
|
194
|
+
/** Minor units (cents). */
|
|
195
|
+
amountPaid: {
|
|
196
|
+
order: 13,
|
|
197
|
+
fillable: true,
|
|
198
|
+
nullable: true,
|
|
199
|
+
validation: {
|
|
200
|
+
rule: schema.number().min(0),
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
|
|
204
|
+
/** Minor units (cents). A license is revoked once this covers `amountPaid`. */
|
|
205
|
+
amountRefunded: {
|
|
206
|
+
default: 0,
|
|
207
|
+
order: 14,
|
|
208
|
+
fillable: true,
|
|
209
|
+
validation: {
|
|
210
|
+
rule: schema.number().min(0),
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
|
|
214
|
+
currency: {
|
|
215
|
+
order: 15,
|
|
216
|
+
fillable: true,
|
|
217
|
+
nullable: true,
|
|
218
|
+
validation: {
|
|
219
|
+
rule: schema.string().max(3),
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
|
|
223
|
+
revokedAt: {
|
|
224
|
+
order: 16,
|
|
225
|
+
fillable: true,
|
|
226
|
+
nullable: true,
|
|
227
|
+
validation: {
|
|
228
|
+
rule: schema.timestamp(),
|
|
229
|
+
},
|
|
230
|
+
},
|
|
89
231
|
},
|
|
90
232
|
|
|
91
233
|
dashboard: {
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { defineModel } from '@stacksjs/orm'
|
|
2
|
+
import { schema } from '@stacksjs/validation/runtime'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* One person's place on a team license.
|
|
6
|
+
*
|
|
7
|
+
* A team license covers `seats` people. Each seat belongs to a member of the
|
|
8
|
+
* license's team (`TeamMember`), is found by that member's email when they
|
|
9
|
+
* activate a device, and allows the license's `maxDevices` devices of its own.
|
|
10
|
+
*/
|
|
11
|
+
export default defineModel({
|
|
12
|
+
name: 'LicenseSeat',
|
|
13
|
+
table: 'license_seats',
|
|
14
|
+
primaryKey: 'id',
|
|
15
|
+
autoIncrement: true,
|
|
16
|
+
|
|
17
|
+
indexes: [
|
|
18
|
+
{
|
|
19
|
+
name: 'license_seats_license_user_unique',
|
|
20
|
+
columns: ['license_key_id', 'user_id'],
|
|
21
|
+
unique: true,
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
|
|
25
|
+
// Assigned by a team's owner or admin through the license routes.
|
|
26
|
+
ownership: false,
|
|
27
|
+
|
|
28
|
+
belongsTo: ['LicenseKey', 'TeamMember', 'User'],
|
|
29
|
+
|
|
30
|
+
traits: {
|
|
31
|
+
gdpr: { erasure: 'delete', basis: 'contract', purpose: 'License seat assignment' },
|
|
32
|
+
useTimestamps: true,
|
|
33
|
+
useSeeder: { count: 0 },
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
attributes: {
|
|
37
|
+
/** The member's address when the seat was assigned, lower-cased. */
|
|
38
|
+
email: {
|
|
39
|
+
required: true,
|
|
40
|
+
fillable: true,
|
|
41
|
+
personal: true,
|
|
42
|
+
validation: {
|
|
43
|
+
rule: schema.string().required().max(254),
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
assignedAt: {
|
|
47
|
+
required: true,
|
|
48
|
+
fillable: true,
|
|
49
|
+
validation: {
|
|
50
|
+
rule: schema.timestamp().required(),
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
dashboard: { enabled: false },
|
|
56
|
+
} as const)
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@stacksjs/orm",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"sideEffects": false,
|
|
5
|
-
"version": "0.75.
|
|
5
|
+
"version": "0.75.551",
|
|
6
6
|
"description": "The Stacks ORM integration",
|
|
7
7
|
"author": "Chris Breuer",
|
|
8
8
|
"contributors": [
|
|
@@ -63,53 +63,46 @@
|
|
|
63
63
|
"prepublishOnly": "bun run build"
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@stacksjs/cache": "0.75.
|
|
67
|
-
"@stacksjs/cli": "0.75.
|
|
68
|
-
"@stacksjs/config": "0.75.
|
|
69
|
-
"@stacksjs/database": "0.75.
|
|
70
|
-
"@stacksjs/env": "0.75.
|
|
71
|
-
"@stacksjs/error-handling": "0.75.
|
|
72
|
-
"@stacksjs/events": "0.75.
|
|
73
|
-
"@stacksjs/logging": "0.75.
|
|
74
|
-
"@stacksjs/model-meta": "0.75.
|
|
75
|
-
"@stacksjs/pagination": "0.75.
|
|
76
|
-
"@stacksjs/path": "0.75.
|
|
77
|
-
"@stacksjs/query-builder": "0.75.
|
|
78
|
-
"@stacksjs/realtime": "0.75.
|
|
79
|
-
"@stacksjs/router": "0.75.
|
|
80
|
-
"@stacksjs/storage": "0.75.
|
|
81
|
-
"@stacksjs/strings": "0.75.
|
|
66
|
+
"@stacksjs/cache": "0.75.551",
|
|
67
|
+
"@stacksjs/cli": "0.75.551",
|
|
68
|
+
"@stacksjs/config": "0.75.551",
|
|
69
|
+
"@stacksjs/database": "0.75.551",
|
|
70
|
+
"@stacksjs/env": "0.75.551",
|
|
71
|
+
"@stacksjs/error-handling": "0.75.551",
|
|
72
|
+
"@stacksjs/events": "0.75.551",
|
|
73
|
+
"@stacksjs/logging": "0.75.551",
|
|
74
|
+
"@stacksjs/model-meta": "0.75.551",
|
|
75
|
+
"@stacksjs/pagination": "0.75.551",
|
|
76
|
+
"@stacksjs/path": "0.75.551",
|
|
77
|
+
"@stacksjs/query-builder": "0.75.551",
|
|
78
|
+
"@stacksjs/realtime": "0.75.551",
|
|
79
|
+
"@stacksjs/router": "0.75.551",
|
|
80
|
+
"@stacksjs/storage": "0.75.551",
|
|
81
|
+
"@stacksjs/strings": "0.75.551",
|
|
82
82
|
"@stacksjs/ts-validation": "^0.5.7",
|
|
83
|
-
"@stacksjs/validation": "0.75.
|
|
84
|
-
"bun-query-builder": "^0.3.44"
|
|
83
|
+
"@stacksjs/validation": "0.75.551",
|
|
84
|
+
"bun-query-builder": "^0.3.44",
|
|
85
|
+
"stripe": "23.0.0"
|
|
85
86
|
},
|
|
86
87
|
"peerDependencies": {
|
|
87
|
-
"@stacksjs/auth": "0.75.
|
|
88
|
-
"@stacksjs/payments": "0.75.
|
|
89
|
-
"@stacksjs/queue": "0.75.
|
|
90
|
-
"@stacksjs/search-engine": "0.75.
|
|
91
|
-
"stripe": "23.0.0"
|
|
88
|
+
"@stacksjs/auth": "0.75.551",
|
|
89
|
+
"@stacksjs/payments": "0.75.551",
|
|
90
|
+
"@stacksjs/queue": "0.75.551",
|
|
91
|
+
"@stacksjs/search-engine": "0.75.551"
|
|
92
92
|
},
|
|
93
93
|
"peerDependenciesMeta": {
|
|
94
94
|
"@stacksjs/auth": {
|
|
95
95
|
"optional": true
|
|
96
96
|
},
|
|
97
|
-
"@stacksjs/payments": {
|
|
98
|
-
"optional": true
|
|
99
|
-
},
|
|
100
97
|
"@stacksjs/queue": {
|
|
101
98
|
"optional": true
|
|
102
99
|
},
|
|
103
100
|
"@stacksjs/search-engine": {
|
|
104
101
|
"optional": true
|
|
105
|
-
},
|
|
106
|
-
"stripe": {
|
|
107
|
-
"optional": true
|
|
108
102
|
}
|
|
109
103
|
},
|
|
110
104
|
"devDependencies": {
|
|
111
|
-
"@stacksjs/types": "0.75.
|
|
112
|
-
"better-dx": "^0.2.24"
|
|
113
|
-
"stripe": "23.0.0"
|
|
105
|
+
"@stacksjs/types": "0.75.551",
|
|
106
|
+
"better-dx": "^0.2.24"
|
|
114
107
|
}
|
|
115
108
|
}
|