@gravito/pulse 2.0.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +308 -117
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7153,6 +7153,59 @@ var init_src = __esm(() => {
|
|
|
7153
7153
|
init_dist();
|
|
7154
7154
|
});
|
|
7155
7155
|
|
|
7156
|
+
// ../atlas/src/errors/index.ts
|
|
7157
|
+
var DatabaseError, ConstraintViolationError, UniqueConstraintError, ForeignKeyConstraintError, NotNullConstraintError, TableNotFoundError, ConnectionError;
|
|
7158
|
+
var init_errors = __esm(() => {
|
|
7159
|
+
DatabaseError = class DatabaseError extends Error {
|
|
7160
|
+
originalError;
|
|
7161
|
+
query;
|
|
7162
|
+
bindings;
|
|
7163
|
+
constructor(message, originalError, query, bindings) {
|
|
7164
|
+
super(message);
|
|
7165
|
+
this.name = "DatabaseError";
|
|
7166
|
+
this.originalError = originalError;
|
|
7167
|
+
this.query = query;
|
|
7168
|
+
this.bindings = bindings;
|
|
7169
|
+
}
|
|
7170
|
+
};
|
|
7171
|
+
ConstraintViolationError = class ConstraintViolationError extends DatabaseError {
|
|
7172
|
+
constructor(message, originalError, query, bindings) {
|
|
7173
|
+
super(message, originalError, query, bindings);
|
|
7174
|
+
this.name = "ConstraintViolationError";
|
|
7175
|
+
}
|
|
7176
|
+
};
|
|
7177
|
+
UniqueConstraintError = class UniqueConstraintError extends ConstraintViolationError {
|
|
7178
|
+
constructor(message, originalError, query, bindings) {
|
|
7179
|
+
super(message, originalError, query, bindings);
|
|
7180
|
+
this.name = "UniqueConstraintError";
|
|
7181
|
+
}
|
|
7182
|
+
};
|
|
7183
|
+
ForeignKeyConstraintError = class ForeignKeyConstraintError extends ConstraintViolationError {
|
|
7184
|
+
constructor(message, originalError, query, bindings) {
|
|
7185
|
+
super(message, originalError, query, bindings);
|
|
7186
|
+
this.name = "ForeignKeyConstraintError";
|
|
7187
|
+
}
|
|
7188
|
+
};
|
|
7189
|
+
NotNullConstraintError = class NotNullConstraintError extends ConstraintViolationError {
|
|
7190
|
+
constructor(message, originalError, query, bindings) {
|
|
7191
|
+
super(message, originalError, query, bindings);
|
|
7192
|
+
this.name = "NotNullConstraintError";
|
|
7193
|
+
}
|
|
7194
|
+
};
|
|
7195
|
+
TableNotFoundError = class TableNotFoundError extends DatabaseError {
|
|
7196
|
+
constructor(message, originalError, query, bindings) {
|
|
7197
|
+
super(message, originalError, query, bindings);
|
|
7198
|
+
this.name = "TableNotFoundError";
|
|
7199
|
+
}
|
|
7200
|
+
};
|
|
7201
|
+
ConnectionError = class ConnectionError extends DatabaseError {
|
|
7202
|
+
constructor(message, originalError) {
|
|
7203
|
+
super(message, originalError);
|
|
7204
|
+
this.name = "ConnectionError";
|
|
7205
|
+
}
|
|
7206
|
+
};
|
|
7207
|
+
});
|
|
7208
|
+
|
|
7156
7209
|
// ../../node_modules/.bun/bson@6.10.4/node_modules/bson/lib/bson.cjs
|
|
7157
7210
|
var require_bson = __commonJS((exports) => {
|
|
7158
7211
|
var TypedArrayPrototypeGetSymbolToStringTag = (() => {
|
|
@@ -40473,71 +40526,20 @@ var require_lib4 = __commonJS((exports) => {
|
|
|
40473
40526
|
} });
|
|
40474
40527
|
});
|
|
40475
40528
|
|
|
40476
|
-
// ../atlas/src/errors/index.ts
|
|
40477
|
-
var DatabaseError, ConstraintViolationError, UniqueConstraintError, ForeignKeyConstraintError, NotNullConstraintError, TableNotFoundError, ConnectionError;
|
|
40478
|
-
var init_errors = __esm(() => {
|
|
40479
|
-
DatabaseError = class DatabaseError extends Error {
|
|
40480
|
-
originalError;
|
|
40481
|
-
query;
|
|
40482
|
-
bindings;
|
|
40483
|
-
constructor(message, originalError, query, bindings) {
|
|
40484
|
-
super(message);
|
|
40485
|
-
this.name = "DatabaseError";
|
|
40486
|
-
this.originalError = originalError;
|
|
40487
|
-
this.query = query;
|
|
40488
|
-
this.bindings = bindings;
|
|
40489
|
-
}
|
|
40490
|
-
};
|
|
40491
|
-
ConstraintViolationError = class ConstraintViolationError extends DatabaseError {
|
|
40492
|
-
constructor(message, originalError, query, bindings) {
|
|
40493
|
-
super(message, originalError, query, bindings);
|
|
40494
|
-
this.name = "ConstraintViolationError";
|
|
40495
|
-
}
|
|
40496
|
-
};
|
|
40497
|
-
UniqueConstraintError = class UniqueConstraintError extends ConstraintViolationError {
|
|
40498
|
-
constructor(message, originalError, query, bindings) {
|
|
40499
|
-
super(message, originalError, query, bindings);
|
|
40500
|
-
this.name = "UniqueConstraintError";
|
|
40501
|
-
}
|
|
40502
|
-
};
|
|
40503
|
-
ForeignKeyConstraintError = class ForeignKeyConstraintError extends ConstraintViolationError {
|
|
40504
|
-
constructor(message, originalError, query, bindings) {
|
|
40505
|
-
super(message, originalError, query, bindings);
|
|
40506
|
-
this.name = "ForeignKeyConstraintError";
|
|
40507
|
-
}
|
|
40508
|
-
};
|
|
40509
|
-
NotNullConstraintError = class NotNullConstraintError extends ConstraintViolationError {
|
|
40510
|
-
constructor(message, originalError, query, bindings) {
|
|
40511
|
-
super(message, originalError, query, bindings);
|
|
40512
|
-
this.name = "NotNullConstraintError";
|
|
40513
|
-
}
|
|
40514
|
-
};
|
|
40515
|
-
TableNotFoundError = class TableNotFoundError extends DatabaseError {
|
|
40516
|
-
constructor(message, originalError, query, bindings) {
|
|
40517
|
-
super(message, originalError, query, bindings);
|
|
40518
|
-
this.name = "TableNotFoundError";
|
|
40519
|
-
}
|
|
40520
|
-
};
|
|
40521
|
-
ConnectionError = class ConnectionError extends DatabaseError {
|
|
40522
|
-
constructor(message, originalError) {
|
|
40523
|
-
super(message, originalError);
|
|
40524
|
-
this.name = "ConnectionError";
|
|
40525
|
-
}
|
|
40526
|
-
};
|
|
40527
|
-
});
|
|
40528
|
-
|
|
40529
40529
|
// ../atlas/src/drivers/MongoDBDriver.ts
|
|
40530
40530
|
class MongoDBDriver {
|
|
40531
40531
|
config;
|
|
40532
40532
|
client = null;
|
|
40533
40533
|
db = null;
|
|
40534
40534
|
MongoClientCtor;
|
|
40535
|
-
constructor(config, deps
|
|
40535
|
+
constructor(config, deps) {
|
|
40536
40536
|
if (config.driver !== "mongodb") {
|
|
40537
|
-
throw new Error(`Invalid driver type '
|
|
40537
|
+
throw new Error(`Invalid driver type '${config.driver}' for MongoDBDriver`);
|
|
40538
40538
|
}
|
|
40539
40539
|
this.config = config;
|
|
40540
|
-
|
|
40540
|
+
if (deps?.MongoClient) {
|
|
40541
|
+
this.MongoClientCtor = deps.MongoClient;
|
|
40542
|
+
}
|
|
40541
40543
|
}
|
|
40542
40544
|
getDriverName() {
|
|
40543
40545
|
return "mongodb";
|
|
@@ -40547,13 +40549,22 @@ class MongoDBDriver {
|
|
|
40547
40549
|
return;
|
|
40548
40550
|
}
|
|
40549
40551
|
try {
|
|
40550
|
-
|
|
40552
|
+
const Ctor = this.MongoClientCtor || (await this.loadMongoModule()).MongoClient;
|
|
40553
|
+
this.client = new Ctor(this.config.uri ?? `mongodb://${this.config.host}:${this.config.port}/${this.config.database}`);
|
|
40551
40554
|
await this.client.connect();
|
|
40552
40555
|
this.db = this.client.db(this.config.database);
|
|
40553
40556
|
} catch (error) {
|
|
40554
40557
|
throw new ConnectionError("Could not connect to MongoDB cluster", error);
|
|
40555
40558
|
}
|
|
40556
40559
|
}
|
|
40560
|
+
async loadMongoModule() {
|
|
40561
|
+
try {
|
|
40562
|
+
const mongodb = await Promise.resolve().then(() => __toESM(require_lib4(), 1));
|
|
40563
|
+
return mongodb;
|
|
40564
|
+
} catch (e) {
|
|
40565
|
+
throw new Error(`MongoDB driver requires the "mongodb" package. Please install it: bun add mongodb. Original Error: ${e}`);
|
|
40566
|
+
}
|
|
40567
|
+
}
|
|
40557
40568
|
async disconnect() {
|
|
40558
40569
|
if (this.client) {
|
|
40559
40570
|
await this.client.close();
|
|
@@ -40646,10 +40657,8 @@ class MongoDBDriver {
|
|
|
40646
40657
|
return doc;
|
|
40647
40658
|
}
|
|
40648
40659
|
}
|
|
40649
|
-
var import_mongodb;
|
|
40650
40660
|
var init_MongoDBDriver = __esm(() => {
|
|
40651
40661
|
init_errors();
|
|
40652
|
-
import_mongodb = __toESM(require_lib4(), 1);
|
|
40653
40662
|
});
|
|
40654
40663
|
|
|
40655
40664
|
// ../../node_modules/.bun/sqlstring@2.3.3/node_modules/sqlstring/lib/SqlString.js
|
|
@@ -74589,12 +74598,14 @@ class RedisDriver {
|
|
|
74589
74598
|
config;
|
|
74590
74599
|
client = null;
|
|
74591
74600
|
RedisCtor;
|
|
74592
|
-
constructor(config, deps
|
|
74601
|
+
constructor(config, deps) {
|
|
74593
74602
|
if (config.driver !== "redis") {
|
|
74594
74603
|
throw new Error(`Invalid driver type '${config.driver}' for RedisDriver`);
|
|
74595
74604
|
}
|
|
74596
74605
|
this.config = config;
|
|
74597
|
-
|
|
74606
|
+
if (deps?.Redis) {
|
|
74607
|
+
this.RedisCtor = deps.Redis;
|
|
74608
|
+
}
|
|
74598
74609
|
}
|
|
74599
74610
|
getDriverName() {
|
|
74600
74611
|
return "redis";
|
|
@@ -74604,7 +74615,8 @@ class RedisDriver {
|
|
|
74604
74615
|
return;
|
|
74605
74616
|
}
|
|
74606
74617
|
try {
|
|
74607
|
-
this.
|
|
74618
|
+
const Ctor = this.RedisCtor || (await this.loadRedisModule()).default;
|
|
74619
|
+
this.client = new Ctor({
|
|
74608
74620
|
host: this.config.host,
|
|
74609
74621
|
port: this.config.port ?? 6379,
|
|
74610
74622
|
password: this.config.password,
|
|
@@ -74616,6 +74628,14 @@ class RedisDriver {
|
|
|
74616
74628
|
throw new ConnectionError("Could not connect to Redis host", error);
|
|
74617
74629
|
}
|
|
74618
74630
|
}
|
|
74631
|
+
async loadRedisModule() {
|
|
74632
|
+
try {
|
|
74633
|
+
const ioredis = await Promise.resolve().then(() => __toESM(require_built3(), 1));
|
|
74634
|
+
return ioredis;
|
|
74635
|
+
} catch (e) {
|
|
74636
|
+
throw new Error(`Redis driver requires the "ioredis" package. Please install it: bun add ioredis. Original Error: ${e}`);
|
|
74637
|
+
}
|
|
74638
|
+
}
|
|
74619
74639
|
async disconnect() {
|
|
74620
74640
|
if (this.client) {
|
|
74621
74641
|
await this.client.quit();
|
|
@@ -74687,10 +74707,8 @@ class RedisDriver {
|
|
|
74687
74707
|
return false;
|
|
74688
74708
|
}
|
|
74689
74709
|
}
|
|
74690
|
-
var import_ioredis;
|
|
74691
74710
|
var init_RedisDriver = __esm(() => {
|
|
74692
74711
|
init_errors();
|
|
74693
|
-
import_ioredis = __toESM(require_built3(), 1);
|
|
74694
74712
|
});
|
|
74695
74713
|
|
|
74696
74714
|
// ../../node_modules/.bun/better-sqlite3@11.10.0/node_modules/better-sqlite3/lib/util.js
|
|
@@ -75485,11 +75503,15 @@ class SQLiteDriver {
|
|
|
75485
75503
|
});
|
|
75486
75504
|
this.client.exec("PRAGMA journal_mode = WAL;");
|
|
75487
75505
|
} else {
|
|
75488
|
-
|
|
75489
|
-
|
|
75490
|
-
|
|
75491
|
-
|
|
75492
|
-
|
|
75506
|
+
try {
|
|
75507
|
+
const { default: Database } = await Promise.resolve().then(() => __toESM(require_lib11(), 1));
|
|
75508
|
+
this.client = new Database(this.config.database, {
|
|
75509
|
+
readonly: this.config.readonly ?? false
|
|
75510
|
+
});
|
|
75511
|
+
this.client.pragma("journal_mode = WAL");
|
|
75512
|
+
} catch (e) {
|
|
75513
|
+
throw new Error(`SQLite driver requires "better-sqlite3" when running in Node.js. Please install it: bun add better-sqlite3. Original Error: ${e}`);
|
|
75514
|
+
}
|
|
75493
75515
|
}
|
|
75494
75516
|
} catch (error) {
|
|
75495
75517
|
throw new ConnectionError("Could not connect to SQLite database", error);
|
|
@@ -77756,7 +77778,7 @@ var init_Connection = __esm(() => {
|
|
|
77756
77778
|
return new Proxy(this, {
|
|
77757
77779
|
get(target, prop) {
|
|
77758
77780
|
if (prop in target) {
|
|
77759
|
-
return target
|
|
77781
|
+
return Reflect.get(target, prop);
|
|
77760
77782
|
}
|
|
77761
77783
|
if (typeof prop === "string" && target.driver && typeof target.driver[prop] === "function") {
|
|
77762
77784
|
return target.driver[prop].bind(target.driver);
|
|
@@ -83334,6 +83356,8 @@ export class ${name}ServiceProvider extends ServiceProvider {
|
|
|
83334
83356
|
return `export default {
|
|
83335
83357
|
name: process.env.APP_NAME ?? '${context.name}',
|
|
83336
83358
|
env: process.env.APP_ENV ?? 'development',
|
|
83359
|
+
port: Number.parseInt(process.env.PORT ?? '3000', 10),
|
|
83360
|
+
VIEW_DIR: process.env.VIEW_DIR ?? 'src/views',
|
|
83337
83361
|
debug: process.env.APP_DEBUG === 'true',
|
|
83338
83362
|
url: process.env.APP_URL ?? 'http://localhost:3000',
|
|
83339
83363
|
}
|
|
@@ -83980,6 +84004,16 @@ export default {
|
|
|
83980
84004
|
*/
|
|
83981
84005
|
env: process.env.APP_ENV ?? 'development',
|
|
83982
84006
|
|
|
84007
|
+
/**
|
|
84008
|
+
* Application port
|
|
84009
|
+
*/
|
|
84010
|
+
port: Number.parseInt(process.env.PORT ?? '3000', 10),
|
|
84011
|
+
|
|
84012
|
+
/**
|
|
84013
|
+
* View directory
|
|
84014
|
+
*/
|
|
84015
|
+
VIEW_DIR: process.env.VIEW_DIR ?? 'src/views',
|
|
84016
|
+
|
|
83983
84017
|
/**
|
|
83984
84018
|
* Debug mode
|
|
83985
84019
|
*/
|
|
@@ -84103,8 +84137,7 @@ export default {
|
|
|
84103
84137
|
*/
|
|
84104
84138
|
providers: {
|
|
84105
84139
|
users: {
|
|
84106
|
-
driver: '
|
|
84107
|
-
table: 'users',
|
|
84140
|
+
driver: 'callback', // Custom callback provider
|
|
84108
84141
|
},
|
|
84109
84142
|
},
|
|
84110
84143
|
}
|
|
@@ -85352,6 +85385,8 @@ class ActionDomainGenerator extends BaseGenerator {
|
|
|
85352
85385
|
return `export default {
|
|
85353
85386
|
name: process.env.APP_NAME ?? '${context.name}',
|
|
85354
85387
|
env: process.env.APP_ENV ?? 'development',
|
|
85388
|
+
port: Number.parseInt(process.env.PORT ?? '3000', 10),
|
|
85389
|
+
VIEW_DIR: process.env.VIEW_DIR ?? 'src/views',
|
|
85355
85390
|
debug: process.env.APP_DEBUG === 'true',
|
|
85356
85391
|
url: process.env.APP_URL ?? 'http://localhost:3000',
|
|
85357
85392
|
key: process.env.APP_KEY,
|
|
@@ -85669,6 +85704,115 @@ Created with \u2764\uFE0F using Gravito Framework
|
|
|
85669
85704
|
}
|
|
85670
85705
|
}
|
|
85671
85706
|
|
|
85707
|
+
// ../scaffold/src/generators/StandaloneEngineGenerator.ts
|
|
85708
|
+
class StandaloneEngineGenerator extends BaseGenerator {
|
|
85709
|
+
get architectureType() {
|
|
85710
|
+
return "standalone-engine";
|
|
85711
|
+
}
|
|
85712
|
+
get displayName() {
|
|
85713
|
+
return "Standalone Engine";
|
|
85714
|
+
}
|
|
85715
|
+
get description() {
|
|
85716
|
+
return "High-performance pure Gravito Engine (minimal)";
|
|
85717
|
+
}
|
|
85718
|
+
getDirectoryStructure(context) {
|
|
85719
|
+
return [
|
|
85720
|
+
{
|
|
85721
|
+
type: "directory",
|
|
85722
|
+
name: "src",
|
|
85723
|
+
children: [
|
|
85724
|
+
{
|
|
85725
|
+
type: "file",
|
|
85726
|
+
name: "index.ts",
|
|
85727
|
+
content: this.getIndexContent()
|
|
85728
|
+
}
|
|
85729
|
+
]
|
|
85730
|
+
},
|
|
85731
|
+
{
|
|
85732
|
+
type: "file",
|
|
85733
|
+
name: "README.md",
|
|
85734
|
+
content: this.getReadmeContent(context)
|
|
85735
|
+
}
|
|
85736
|
+
];
|
|
85737
|
+
}
|
|
85738
|
+
async generateCommonFiles(context) {
|
|
85739
|
+
await this.writeFile(context.targetDir, "package.json", this.generatePackageJson(context));
|
|
85740
|
+
await this.writeFile(context.targetDir, "tsconfig.json", this.generateTsConfig());
|
|
85741
|
+
await this.writeFile(context.targetDir, ".gitignore", this.generateGitignore());
|
|
85742
|
+
}
|
|
85743
|
+
generatePackageJson(context) {
|
|
85744
|
+
const pkg = {
|
|
85745
|
+
name: context.nameKebabCase,
|
|
85746
|
+
version: "0.1.0",
|
|
85747
|
+
type: "module",
|
|
85748
|
+
scripts: {
|
|
85749
|
+
dev: "bun run --watch src/index.ts",
|
|
85750
|
+
build: "bun build ./src/index.ts --outdir ./dist --target bun",
|
|
85751
|
+
start: "bun run dist/index.js",
|
|
85752
|
+
test: "bun test"
|
|
85753
|
+
},
|
|
85754
|
+
dependencies: {
|
|
85755
|
+
"@gravito/core": "^1.1.0"
|
|
85756
|
+
},
|
|
85757
|
+
devDependencies: {
|
|
85758
|
+
"bun-types": "latest",
|
|
85759
|
+
typescript: "^5.0.0"
|
|
85760
|
+
}
|
|
85761
|
+
};
|
|
85762
|
+
return JSON.stringify(pkg, null, 2);
|
|
85763
|
+
}
|
|
85764
|
+
generateArchitectureDoc(_context) {
|
|
85765
|
+
return "";
|
|
85766
|
+
}
|
|
85767
|
+
getIndexContent() {
|
|
85768
|
+
return `import { Gravito } from '@gravito/core/engine'
|
|
85769
|
+
|
|
85770
|
+
const app = new Gravito()
|
|
85771
|
+
|
|
85772
|
+
// Basic Route
|
|
85773
|
+
app.get('/', (c) => c.text('Hello Gravito Engine!'))
|
|
85774
|
+
|
|
85775
|
+
// JSON Response
|
|
85776
|
+
app.get('/json', (c) => c.json({ message: 'High Performance' }))
|
|
85777
|
+
|
|
85778
|
+
// Path Parameters
|
|
85779
|
+
app.get('/user/:name', (c) => {
|
|
85780
|
+
const name = c.req.param('name')
|
|
85781
|
+
return c.text(\`Hello \${name}\`)
|
|
85782
|
+
})
|
|
85783
|
+
|
|
85784
|
+
export default app
|
|
85785
|
+
`;
|
|
85786
|
+
}
|
|
85787
|
+
getReadmeContent(context) {
|
|
85788
|
+
return `# ${context.name}
|
|
85789
|
+
|
|
85790
|
+
A high-performance web application powered by Gravito Engine.
|
|
85791
|
+
|
|
85792
|
+
## Getting Started
|
|
85793
|
+
|
|
85794
|
+
### Install Dependencies
|
|
85795
|
+
|
|
85796
|
+
\`\`\`bash
|
|
85797
|
+
bun install
|
|
85798
|
+
\`\`\`
|
|
85799
|
+
|
|
85800
|
+
### Run Development Server
|
|
85801
|
+
|
|
85802
|
+
\`\`\`bash
|
|
85803
|
+
bun run dev
|
|
85804
|
+
\`\`\`
|
|
85805
|
+
|
|
85806
|
+
### Production Build
|
|
85807
|
+
|
|
85808
|
+
\`\`\`bash
|
|
85809
|
+
bun run build
|
|
85810
|
+
bun start
|
|
85811
|
+
\`\`\`
|
|
85812
|
+
`;
|
|
85813
|
+
}
|
|
85814
|
+
}
|
|
85815
|
+
|
|
85672
85816
|
// ../scaffold/src/Scaffold.ts
|
|
85673
85817
|
var __dirname = "/Users/carl/Dev/Carl/gravito-core/packages/scaffold/src";
|
|
85674
85818
|
|
|
@@ -85701,6 +85845,11 @@ class Scaffold {
|
|
|
85701
85845
|
name: "Action Domain",
|
|
85702
85846
|
description: "Single Action Controllers pattern for high-clarity APIs"
|
|
85703
85847
|
},
|
|
85848
|
+
{
|
|
85849
|
+
type: "standalone-engine",
|
|
85850
|
+
name: "Standalone Engine",
|
|
85851
|
+
description: "High-performance pure Gravito Engine (minimal)"
|
|
85852
|
+
},
|
|
85704
85853
|
{
|
|
85705
85854
|
type: "satellite",
|
|
85706
85855
|
name: "Gravito Satellite",
|
|
@@ -85758,6 +85907,8 @@ class Scaffold {
|
|
|
85758
85907
|
return new ActionDomainGenerator(config);
|
|
85759
85908
|
case "satellite":
|
|
85760
85909
|
return new SatelliteGenerator(config);
|
|
85910
|
+
case "standalone-engine":
|
|
85911
|
+
return new StandaloneEngineGenerator(config);
|
|
85761
85912
|
default:
|
|
85762
85913
|
throw new Error(`Unknown architecture type: ${type}`);
|
|
85763
85914
|
}
|
|
@@ -85781,7 +85932,7 @@ import { confirm, note, spinner } from "@clack/prompts";
|
|
|
85781
85932
|
// ../core/package.json
|
|
85782
85933
|
var package_default = {
|
|
85783
85934
|
name: "@gravito/core",
|
|
85784
|
-
version: "1.
|
|
85935
|
+
version: "1.2.0",
|
|
85785
85936
|
description: "",
|
|
85786
85937
|
module: "./dist/index.js",
|
|
85787
85938
|
main: "./dist/index.cjs",
|
|
@@ -85858,6 +86009,36 @@ class PhotonRequestWrapper {
|
|
|
85858
86009
|
constructor(photonCtx) {
|
|
85859
86010
|
this.photonCtx = photonCtx;
|
|
85860
86011
|
}
|
|
86012
|
+
static create(photonCtx) {
|
|
86013
|
+
const instance = new PhotonRequestWrapper(photonCtx);
|
|
86014
|
+
return new Proxy(instance, {
|
|
86015
|
+
get(target, prop, receiver) {
|
|
86016
|
+
if (prop in target) {
|
|
86017
|
+
const value = Reflect.get(target, prop, receiver);
|
|
86018
|
+
if (typeof value === "function") {
|
|
86019
|
+
return value.bind(target);
|
|
86020
|
+
}
|
|
86021
|
+
return value;
|
|
86022
|
+
}
|
|
86023
|
+
const nativeReq = target.photonCtx.req;
|
|
86024
|
+
if (prop in nativeReq) {
|
|
86025
|
+
const value = nativeReq[prop];
|
|
86026
|
+
if (typeof value === "function") {
|
|
86027
|
+
return value.bind(nativeReq);
|
|
86028
|
+
}
|
|
86029
|
+
return value;
|
|
86030
|
+
}
|
|
86031
|
+
return;
|
|
86032
|
+
},
|
|
86033
|
+
set(target, prop, value) {
|
|
86034
|
+
if (prop in target) {
|
|
86035
|
+
return Reflect.set(target, prop, value);
|
|
86036
|
+
}
|
|
86037
|
+
target.photonCtx.req[prop] = value;
|
|
86038
|
+
return true;
|
|
86039
|
+
}
|
|
86040
|
+
});
|
|
86041
|
+
}
|
|
85861
86042
|
get url() {
|
|
85862
86043
|
return this.photonCtx.req.url;
|
|
85863
86044
|
}
|
|
@@ -85919,7 +86100,7 @@ class PhotonContextWrapper {
|
|
|
85919
86100
|
_req;
|
|
85920
86101
|
constructor(photonCtx) {
|
|
85921
86102
|
this.photonCtx = photonCtx;
|
|
85922
|
-
this._req =
|
|
86103
|
+
this._req = PhotonRequestWrapper.create(photonCtx);
|
|
85923
86104
|
}
|
|
85924
86105
|
static create(photonCtx) {
|
|
85925
86106
|
const instance = new PhotonContextWrapper(photonCtx);
|
|
@@ -86026,7 +86207,7 @@ function toPhotonMiddleware(middleware) {
|
|
|
86026
86207
|
return async (c, next) => {
|
|
86027
86208
|
const ctx = PhotonContextWrapper.create(c);
|
|
86028
86209
|
const gravitoNext = async () => {
|
|
86029
|
-
await next();
|
|
86210
|
+
return await next();
|
|
86030
86211
|
};
|
|
86031
86212
|
return middleware(ctx, gravitoNext);
|
|
86032
86213
|
};
|
|
@@ -87684,20 +87865,20 @@ class RouteGroup {
|
|
|
87684
87865
|
group(callback) {
|
|
87685
87866
|
callback(this);
|
|
87686
87867
|
}
|
|
87687
|
-
get(path4,
|
|
87688
|
-
return this.router.req("get", path4,
|
|
87868
|
+
get(path4, requestOrHandlerOrMiddleware, handler) {
|
|
87869
|
+
return this.router.req("get", path4, requestOrHandlerOrMiddleware, handler, this.options);
|
|
87689
87870
|
}
|
|
87690
|
-
post(path4,
|
|
87691
|
-
return this.router.req("post", path4,
|
|
87871
|
+
post(path4, requestOrHandlerOrMiddleware, handler) {
|
|
87872
|
+
return this.router.req("post", path4, requestOrHandlerOrMiddleware, handler, this.options);
|
|
87692
87873
|
}
|
|
87693
|
-
put(path4,
|
|
87694
|
-
return this.router.req("put", path4,
|
|
87874
|
+
put(path4, requestOrHandlerOrMiddleware, handler) {
|
|
87875
|
+
return this.router.req("put", path4, requestOrHandlerOrMiddleware, handler, this.options);
|
|
87695
87876
|
}
|
|
87696
|
-
delete(path4,
|
|
87697
|
-
return this.router.req("delete", path4,
|
|
87877
|
+
delete(path4, requestOrHandlerOrMiddleware, handler) {
|
|
87878
|
+
return this.router.req("delete", path4, requestOrHandlerOrMiddleware, handler, this.options);
|
|
87698
87879
|
}
|
|
87699
|
-
patch(path4,
|
|
87700
|
-
return this.router.req("patch", path4,
|
|
87880
|
+
patch(path4, requestOrHandlerOrMiddleware, handler) {
|
|
87881
|
+
return this.router.req("patch", path4, requestOrHandlerOrMiddleware, handler, this.options);
|
|
87701
87882
|
}
|
|
87702
87883
|
resource(name, controller, options = {}) {
|
|
87703
87884
|
const actions = [
|
|
@@ -87842,20 +88023,20 @@ class Router {
|
|
|
87842
88023
|
middleware(...handlers) {
|
|
87843
88024
|
return new RouteGroup(this, { middleware: handlers.flat() });
|
|
87844
88025
|
}
|
|
87845
|
-
get(path4,
|
|
87846
|
-
return this.req("get", path4,
|
|
88026
|
+
get(path4, requestOrHandlerOrMiddleware, handler) {
|
|
88027
|
+
return this.req("get", path4, requestOrHandlerOrMiddleware, handler);
|
|
87847
88028
|
}
|
|
87848
|
-
post(path4,
|
|
87849
|
-
return this.req("post", path4,
|
|
88029
|
+
post(path4, requestOrHandlerOrMiddleware, handler) {
|
|
88030
|
+
return this.req("post", path4, requestOrHandlerOrMiddleware, handler);
|
|
87850
88031
|
}
|
|
87851
|
-
put(path4,
|
|
87852
|
-
return this.req("put", path4,
|
|
88032
|
+
put(path4, requestOrHandlerOrMiddleware, handler) {
|
|
88033
|
+
return this.req("put", path4, requestOrHandlerOrMiddleware, handler);
|
|
87853
88034
|
}
|
|
87854
|
-
delete(path4,
|
|
87855
|
-
return this.req("delete", path4,
|
|
88035
|
+
delete(path4, requestOrHandlerOrMiddleware, handler) {
|
|
88036
|
+
return this.req("delete", path4, requestOrHandlerOrMiddleware, handler);
|
|
87856
88037
|
}
|
|
87857
|
-
patch(path4,
|
|
87858
|
-
return this.req("patch", path4,
|
|
88038
|
+
patch(path4, requestOrHandlerOrMiddleware, handler) {
|
|
88039
|
+
return this.req("patch", path4, requestOrHandlerOrMiddleware, handler);
|
|
87859
88040
|
}
|
|
87860
88041
|
resource(name, controller, options = {}) {
|
|
87861
88042
|
const actions = [
|
|
@@ -87895,17 +88076,25 @@ class Router {
|
|
|
87895
88076
|
}
|
|
87896
88077
|
}
|
|
87897
88078
|
}
|
|
87898
|
-
req(method, path4,
|
|
88079
|
+
req(method, path4, requestOrHandlerOrMiddleware, handler, options = {}) {
|
|
87899
88080
|
const fullPath = (options.prefix || "") + path4;
|
|
87900
88081
|
let formRequestMiddleware = null;
|
|
88082
|
+
let routeMiddleware = [];
|
|
87901
88083
|
let finalRouteHandler;
|
|
87902
88084
|
if (handler !== undefined) {
|
|
87903
|
-
if (isFormRequestClass(
|
|
87904
|
-
formRequestMiddleware = formRequestToMiddleware(
|
|
88085
|
+
if (isFormRequestClass(requestOrHandlerOrMiddleware)) {
|
|
88086
|
+
formRequestMiddleware = formRequestToMiddleware(requestOrHandlerOrMiddleware);
|
|
88087
|
+
} else {
|
|
88088
|
+
const middleware = requestOrHandlerOrMiddleware;
|
|
88089
|
+
if (Array.isArray(middleware)) {
|
|
88090
|
+
routeMiddleware = middleware;
|
|
88091
|
+
} else {
|
|
88092
|
+
routeMiddleware = [middleware];
|
|
88093
|
+
}
|
|
87905
88094
|
}
|
|
87906
88095
|
finalRouteHandler = handler;
|
|
87907
88096
|
} else {
|
|
87908
|
-
finalRouteHandler =
|
|
88097
|
+
finalRouteHandler = requestOrHandlerOrMiddleware;
|
|
87909
88098
|
}
|
|
87910
88099
|
let resolvedHandler;
|
|
87911
88100
|
if (Array.isArray(finalRouteHandler)) {
|
|
@@ -87921,6 +88110,9 @@ class Router {
|
|
|
87921
88110
|
if (formRequestMiddleware) {
|
|
87922
88111
|
handlers.push(formRequestMiddleware);
|
|
87923
88112
|
}
|
|
88113
|
+
if (routeMiddleware.length > 0) {
|
|
88114
|
+
handlers.push(...routeMiddleware);
|
|
88115
|
+
}
|
|
87924
88116
|
handlers.push(resolvedHandler);
|
|
87925
88117
|
if (options.domain) {
|
|
87926
88118
|
const domainCheck = async (c, next) => {
|
|
@@ -88131,8 +88323,7 @@ class PlanetCore {
|
|
|
88131
88323
|
const cookieJar = new CookieJar(this.encrypter);
|
|
88132
88324
|
c.set("cookieJar", cookieJar);
|
|
88133
88325
|
c.route = (name, params, query) => this.router.url(name, params, query);
|
|
88134
|
-
await next();
|
|
88135
|
-
return;
|
|
88326
|
+
return await next();
|
|
88136
88327
|
});
|
|
88137
88328
|
this.router = new Router(this);
|
|
88138
88329
|
this.adapter.onError(async (err, c) => {
|
|
@@ -88562,7 +88753,7 @@ class AOTRouter {
|
|
|
88562
88753
|
}
|
|
88563
88754
|
return false;
|
|
88564
88755
|
}
|
|
88565
|
-
findDynamicRouteKey(method,
|
|
88756
|
+
findDynamicRouteKey(method, _path) {
|
|
88566
88757
|
for (const key of this.pathMiddleware.keys()) {
|
|
88567
88758
|
if (key.startsWith(`${method}:`)) {
|
|
88568
88759
|
return key;
|
|
@@ -88687,11 +88878,9 @@ class FastRequestImpl {
|
|
|
88687
88878
|
|
|
88688
88879
|
class FastContext {
|
|
88689
88880
|
_req = new FastRequestImpl;
|
|
88690
|
-
_statusCode = 200;
|
|
88691
88881
|
_headers = new Headers;
|
|
88692
88882
|
reset(request, params = {}) {
|
|
88693
88883
|
this._req.reset(request, params);
|
|
88694
|
-
this._statusCode = 200;
|
|
88695
88884
|
this._headers = new Headers;
|
|
88696
88885
|
return this;
|
|
88697
88886
|
}
|
|
@@ -88735,9 +88924,7 @@ class FastContext {
|
|
|
88735
88924
|
header(name, value) {
|
|
88736
88925
|
this._headers.set(name, value);
|
|
88737
88926
|
}
|
|
88738
|
-
status(
|
|
88739
|
-
this._statusCode = code;
|
|
88740
|
-
}
|
|
88927
|
+
status(_code) {}
|
|
88741
88928
|
}
|
|
88742
88929
|
|
|
88743
88930
|
// ../core/src/engine/MinimalContext.ts
|
|
@@ -88967,7 +89154,7 @@ class Gravito {
|
|
|
88967
89154
|
}
|
|
88968
89155
|
return this;
|
|
88969
89156
|
}
|
|
88970
|
-
route(
|
|
89157
|
+
route(_path, _app) {
|
|
88971
89158
|
console.warn("route() method is not yet fully implemented");
|
|
88972
89159
|
return this;
|
|
88973
89160
|
}
|
|
@@ -89101,17 +89288,15 @@ class Gravito {
|
|
|
89101
89288
|
const next = async () => {
|
|
89102
89289
|
if (index < middleware.length) {
|
|
89103
89290
|
const mw = middleware[index++];
|
|
89104
|
-
await mw(ctx, next);
|
|
89291
|
+
return await mw(ctx, next);
|
|
89105
89292
|
}
|
|
89293
|
+
return;
|
|
89106
89294
|
};
|
|
89107
|
-
await next();
|
|
89108
|
-
|
|
89109
|
-
|
|
89110
|
-
async handleNotFound(ctx) {
|
|
89111
|
-
if (this.notFoundHandler) {
|
|
89112
|
-
return await this.notFoundHandler(ctx);
|
|
89295
|
+
const result = await next();
|
|
89296
|
+
if (result instanceof Response) {
|
|
89297
|
+
return result;
|
|
89113
89298
|
}
|
|
89114
|
-
return ctx
|
|
89299
|
+
return await handler(ctx);
|
|
89115
89300
|
}
|
|
89116
89301
|
async handleError(error, ctx) {
|
|
89117
89302
|
if (this.errorHandler) {
|
|
@@ -89673,6 +89858,11 @@ async function initCommand(options = {}) {
|
|
|
89673
89858
|
label: "\uD83C\uDFDB\uFE0F Domain-Driven Design (DDD)",
|
|
89674
89859
|
hint: "\u5B8C\u6574\u7684 DDD \u67B6\u69CB\uFF0C\u5305\u542B Modules\u3001Bounded Contexts"
|
|
89675
89860
|
},
|
|
89861
|
+
{
|
|
89862
|
+
value: "standalone-engine",
|
|
89863
|
+
label: "\uD83D\uDE80 Standalone Engine",
|
|
89864
|
+
hint: "\u7D14\u6DE8\u7684\u9AD8\u6027\u80FD\u5F15\u64CE\uFF0C\u7121\u6846\u67B6\u4F9D\u8CF4 (Pure High-Performance Engine)"
|
|
89865
|
+
},
|
|
89676
89866
|
{
|
|
89677
89867
|
value: "action-domain",
|
|
89678
89868
|
label: "\u26A1 Action-Domain-Responder (ADR)",
|
|
@@ -89786,7 +89976,8 @@ async function initCommand(options = {}) {
|
|
|
89786
89976
|
clean: "\uD83E\uDDC5 Clean Architecture",
|
|
89787
89977
|
ddd: "\uD83C\uDFDB\uFE0F Domain-Driven Design",
|
|
89788
89978
|
satellite: "\uD83D\uDEF0\uFE0F Satellite Service",
|
|
89789
|
-
"action-domain": "\u26A1 Action-Domain-Responder"
|
|
89979
|
+
"action-domain": "\u26A1 Action-Domain-Responder",
|
|
89980
|
+
"standalone-engine": "\uD83D\uDE80 Standalone Engine"
|
|
89790
89981
|
};
|
|
89791
89982
|
note2(`\u5C08\u6848\u540D\u7A31: ${pc3.cyan(projectName)}
|
|
89792
89983
|
\u67B6\u69CB\u6A21\u5F0F: ${pc3.green(archLabels[architecture])}
|