Skip to content

Commit

Permalink
close
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniopresto committed Dec 2, 2024
1 parent 5cf631d commit 8a181fa
Show file tree
Hide file tree
Showing 35 changed files with 146 additions and 152 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "powership",
"version": "5.7.7",
"version": "5.7.12",
"private": true,
"scripts": {
"patch": "run-s patch:*",
Expand Down
4 changes: 2 additions & 2 deletions packages/accounts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@powership/accounts",
"version": "5.7.7",
"version": "5.7.12",
"description": "Powership accounts",
"type": "module",
"main": "./out/index.cjs",
Expand All @@ -22,7 +22,7 @@
"scripts": {
"#postinstall": "node ./scripts/postinstall.js",
"test": "jest --runInBand",
"build": "run-p build:*",
"build": "run-p declarations build:*",
"tswatch": "tsc -p tsconfig.declarations.json --noEmit --watch",
"clear": "rimraf out",
"fix": "run-s fix:* ",
Expand Down
5 changes: 3 additions & 2 deletions packages/babel-plugins/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@powership/babel-plugins",
"version": "5.7.7",
"version": "5.7.12",
"main": "./out/index.js",
"sideEffects": false,
"typings": "./out/index.d.ts",
Expand All @@ -13,7 +13,8 @@
"build-targets": "run-p build",
"fix": "run-s fix:*",
"fix:prettier": "prettier \"src/**/*.ts\" --write",
"fix:lint": "eslint src --ext .ts --fix"
"fix:lint": "eslint src --ext .ts --fix",
"clear": "rimraf out"
},
"description": "powership babel plugins",
"keywords": [],
Expand Down
6 changes: 3 additions & 3 deletions packages/boilerplate/babel-config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ if (!validTargets.includes(TARGET)) {
throw new Error(`Invalid process.env.TARGET "${TARGET}", expected one of ${validTargets}`);
}

const KIND = TARGET.includes('browser') ? 'Browser' : 'Server';
const KIND_INVERT = KIND === 'browser' ? 'Server' : 'Browser';
const KIND = TARGET.includes('browser') ? 'browser' : 'server';
const KIND_INVERT = KIND === 'browser' ? 'server' : 'browser';

const destinationExtension = {
browser: 'cjs',
Expand Down Expand Up @@ -68,7 +68,7 @@ module.exports = function (api) {
[
StripBlocksPlugin,
{
magicComment: `@only${KIND_INVERT}`,
magicComment: `@only-${KIND_INVERT}`,
},
],
[
Expand Down
2 changes: 1 addition & 1 deletion packages/boilerplate/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@powership/boilerplate",
"version": "5.7.7",
"version": "5.7.12",
"author": "antoniopresto <[email protected]>",
"sideEffects": false,
"type": "module",
Expand Down
4 changes: 2 additions & 2 deletions packages/entity/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@powership/entity",
"version": "5.7.7",
"version": "5.7.12",
"type": "module",
"main": "./out/index.cjs",
"module": "./out/index.mjs",
Expand All @@ -18,7 +18,7 @@
"scripts": {
"#postinstall": "node ./scripts/postinstall.js",
"test": "jest --runInBand",
"build": "run-p build:*",
"build": "run-p declarations build:*",
"clear": "rimraf out",
"fix": "run-s fix:* ",
"fix:prettier": "prettier \"src/**/*.ts\" --write",
Expand Down
88 changes: 41 additions & 47 deletions packages/entity/src/Entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {
} from '@powership/transporter';
import {
AnyFunction,
BJSON,
capitalize,
createAsyncPlugin,
createProxy,
Expand Down Expand Up @@ -741,56 +740,51 @@ export function createEntity(
return next(acc);
}, entityResult);

PowershipWatchTypesPubSub.emit('created', {
custom: () => ({
name: entityOptions.name,
imports: [`import { Entity } from 'powership';`],
head: ['export type ID = number | string;'],
body: (() => {
let { type, name, indexes } = (
typeof configOptions === 'function'
? configOptions()
: configOptions
) as EntityOptions;

const typeId = type.optionalId || entityResult.type.id;
const indexesJSON = JSON.stringify(indexes);

const configJSON = [
'{',
`name: "${name}",`,
`indexes: ${indexesJSON},`,
`type: GraphTypeRuntime<RuntimeDefinitions['${typeId}'], RuntimeTypes['${typeId}'], '${typeId}'>,`,
'[K: string]: any,',
'}',
].join('\n');

const config_str =
typeof configOptions === 'function'
? `() => (${configJSON})`
: `${configJSON}`;

return [
'export function createEntity(',
`configOptions:`,
config_str,
'',
`): Entity<RuntimeDefinitions['${typeId}']['def'], ${indexesJSON}>;`,
];
})(),
}),
});
if (process.env.POWERSHIP_GENERATE_ENTITY_TYPES) {
PowershipWatchTypesPubSub.emit('created', {
custom: () => ({
name: entityOptions.name,
imports: [`import { Entity } from 'powership';`],
head: ['export type ID = number | string;'],
body: (() => {
let { type, name, indexes } = (
typeof configOptions === 'function'
? configOptions()
: configOptions
) as EntityOptions;

const typeId = type.optionalId || entityResult.type.id;
const indexesJSON = JSON.stringify(indexes);

const configJSON = [
'{',
`name: "${name}",`,
`indexes: ${indexesJSON},`,
`type: GraphTypeRuntime<RuntimeDefinitions['${typeId}'], RuntimeTypes['${typeId}'], '${typeId}'>,`,
'[K: string]: any,',
'}',
].join('\n');

const config_str =
typeof configOptions === 'function'
? `() => (${configJSON})`
: `${configJSON}`;

return [
'export function createEntity(',
`configOptions:`,
config_str,
'',
`): Entity<RuntimeDefinitions['${typeId}']['def'], ${indexesJSON}>;`,
];
})(),
}),
});
}

return entityResult;
}

setTimeout(() => {
try {
// touching the proxy (probably) before `generateTypes` is called
(entity as AnyEntity).type.id;
} catch (e) {}
}, 300);

return entity;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/logstorm/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "logstorm",
"version": "5.7.7",
"version": "5.7.12",
"typings": "out",
"author": "antoniopresto <[email protected]>",
"type": "module",
Expand All @@ -22,7 +22,7 @@
"license": "MIT",
"scripts": {
"test": "echo ok",
"build": "run-p build:*",
"build": "run-p declarations build:*",
"fix": "run-s fix:*",
"fix:prettier": "prettier \"src/**/*.ts\" --write",
"fix:lint": "eslint src --ext .ts --fix",
Expand Down
4 changes: 2 additions & 2 deletions packages/mongo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@powership/mongo",
"version": "5.7.7",
"version": "5.7.12",
"type": "module",
"main": "./out/index.cjs",
"module": "./out/index.mjs",
Expand All @@ -18,7 +18,7 @@
"#postinstall": "node ./scripts/postinstall.js",
"test": "jest --runInBand",
"tswatch": "tsc --noEmit --watch",
"build": "run-p build:*",
"build": "run-p declarations build:*",
"clear": "rimraf out",
"fix": "run-s fix:* ",
"fix:prettier": "prettier \"src/**/*.ts\" --write",
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-engine/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "plugin-engine",
"version": "5.7.7",
"version": "5.7.12",
"type": "module",
"main": "./out/index.cjs",
"module": "./out/index.mjs",
Expand All @@ -21,7 +21,7 @@
"sideEffects": false,
"scripts": {
"test": "jest",
"build": "run-p build:*",
"build": "run-p declarations build:*",
"clear": "rimraf out",
"fix": "run-s fix:* ",
"fix:prettier": "prettier \"src/**/*.ts\" --write",
Expand Down
2 changes: 1 addition & 1 deletion packages/powership/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "powership",
"version": "5.7.7",
"version": "5.7.12",
"author": "antoniopresto <[email protected]>",
"type": "module",
"main": "./out/index.cjs",
Expand Down
12 changes: 6 additions & 6 deletions packages/powership/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ export * from '@powership/schema';
export * from '@powership/utils';
export * from 'plugin-engine';

// @onlyServer
// @only-server
export * from '@powership/entity';
// @onlyServer
// @only-server
export * from '@powership/transporter';

// @onlyServer
// @only-server
export type { RootFilterOperators } from '@powership/transporter';

// @onlyServer
// @only-server
export * from '@powership/server';

// @onlyServer
// @only-server
export {
BaseRequest,
BaseRequestHandler,
Expand All @@ -26,7 +26,7 @@ export {
ServerLogs,
} from '@powership/server';

// @onlyServer
// @only-server
export type {
Handler,
RouteHandlerCallback,
Expand Down
4 changes: 2 additions & 2 deletions packages/runmate/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "runmate",
"version": "5.7.7",
"version": "5.7.12",
"typings": "out",
"author": "antoniopresto <[email protected]>",
"license": "MIT",
Expand All @@ -23,7 +23,7 @@
"test": "jest --runInBand",
"link": "pnpm prepublishOnly && pnpm link --global",
"ts": "tsc --noEmit",
"build": "run-p build:*",
"build": "run-p declarations build:*",
"clear": "rimraf out",
"fix": "run-s fix:* ",
"fix:prettier": "prettier \"src/**/*.ts\" --write",
Expand Down
4 changes: 2 additions & 2 deletions packages/schema/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@powership/schema",
"version": "5.7.7",
"version": "5.7.12",
"type": "module",
"main": "./out/index.cjs",
"module": "./out/index.mjs",
Expand All @@ -22,7 +22,7 @@
"scripts": {
"test": "jest --runInBand",
"ts": "tsc --noEmit",
"build": "run-p build:*",
"build": "run-p declarations build:*",
"clear": "rimraf out",
"fix": "run-s fix:* ",
"fix:prettier": "prettier \"src/**/*.ts\" --write",
Expand Down
Loading

0 comments on commit 8a181fa

Please sign in to comment.