agentlang 0.3.4 → 0.3.6
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/README.md +82 -29
- package/out/api/http.js +2 -2
- package/out/api/http.js.map +1 -1
- package/out/language/syntax.js +8 -8
- package/out/language/syntax.js.map +1 -1
- package/out/runtime/auth/cognito.d.ts +2 -0
- package/out/runtime/auth/cognito.d.ts.map +1 -1
- package/out/runtime/auth/cognito.js +86 -2
- package/out/runtime/auth/cognito.js.map +1 -1
- package/out/runtime/auth/interface.d.ts +1 -0
- package/out/runtime/auth/interface.d.ts.map +1 -1
- package/out/runtime/exec-graph.d.ts.map +1 -1
- package/out/runtime/exec-graph.js +6 -5
- package/out/runtime/exec-graph.js.map +1 -1
- package/out/runtime/interpreter.d.ts.map +1 -1
- package/out/runtime/interpreter.js +52 -71
- package/out/runtime/interpreter.js.map +1 -1
- package/out/runtime/jsmodules.js +6 -6
- package/out/runtime/jsmodules.js.map +1 -1
- package/out/runtime/loader.js +6 -6
- package/out/runtime/loader.js.map +1 -1
- package/out/runtime/module.d.ts +5 -0
- package/out/runtime/module.d.ts.map +1 -1
- package/out/runtime/module.js +123 -67
- package/out/runtime/module.js.map +1 -1
- package/out/runtime/modules/ai.js +5 -5
- package/out/runtime/modules/ai.js.map +1 -1
- package/out/runtime/modules/auth.d.ts +1 -0
- package/out/runtime/modules/auth.d.ts.map +1 -1
- package/out/runtime/modules/auth.js +54 -19
- package/out/runtime/modules/auth.js.map +1 -1
- package/out/runtime/modules/core.js +1 -1
- package/out/runtime/modules/core.js.map +1 -1
- package/out/runtime/openapi.js +2 -2
- package/out/runtime/openapi.js.map +1 -1
- package/out/runtime/relgraph.js +1 -1
- package/out/runtime/relgraph.js.map +1 -1
- package/out/runtime/resolvers/authinfo.js +2 -2
- package/out/runtime/resolvers/authinfo.js.map +1 -1
- package/out/runtime/resolvers/interface.js +1 -1
- package/out/runtime/resolvers/interface.js.map +1 -1
- package/out/runtime/resolvers/registry.js +1 -1
- package/out/runtime/resolvers/registry.js.map +1 -1
- package/out/runtime/resolvers/sqldb/database.js +11 -11
- package/out/runtime/resolvers/sqldb/database.js.map +1 -1
- package/out/runtime/resolvers/sqldb/impl.js +4 -4
- package/out/runtime/resolvers/sqldb/impl.js.map +1 -1
- package/out/runtime/util.js +5 -5
- package/out/runtime/util.js.map +1 -1
- package/out/utils/runtime.d.ts.map +1 -1
- package/out/utils/runtime.js +2 -2
- package/out/utils/runtime.js.map +1 -1
- package/package.json +4 -3
- package/src/api/http.ts +2 -2
- package/src/language/syntax.ts +8 -8
- package/src/runtime/auth/cognito.ts +107 -2
- package/src/runtime/auth/interface.ts +1 -0
- package/src/runtime/exec-graph.ts +6 -5
- package/src/runtime/interpreter.ts +52 -69
- package/src/runtime/jsmodules.ts +6 -6
- package/src/runtime/loader.ts +6 -6
- package/src/runtime/module.ts +122 -67
- package/src/runtime/modules/ai.ts +5 -5
- package/src/runtime/modules/auth.ts +54 -20
- package/src/runtime/modules/core.ts +1 -1
- package/src/runtime/openapi.ts +2 -2
- package/src/runtime/relgraph.ts +1 -1
- package/src/runtime/resolvers/authinfo.ts +2 -2
- package/src/runtime/resolvers/interface.ts +1 -1
- package/src/runtime/resolvers/registry.ts +1 -1
- package/src/runtime/resolvers/sqldb/database.ts +11 -11
- package/src/runtime/resolvers/sqldb/impl.ts +4 -4
- package/src/runtime/util.ts +5 -5
- package/src/utils/runtime.ts +2 -2
|
@@ -340,6 +340,10 @@ entity Session {
|
|
|
340
340
|
@public workflow acceptInvitation {
|
|
341
341
|
await Auth.acceptInvitationUser(acceptInvitation.email, acceptInvitation.tempPassword, acceptInvitation.newPassword)
|
|
342
342
|
}
|
|
343
|
+
|
|
344
|
+
@public workflow callback {
|
|
345
|
+
await Auth.callbackUser(callback.code)
|
|
346
|
+
}
|
|
343
347
|
`;
|
|
344
348
|
|
|
345
349
|
const evalEvent = makeEventEvaluator(CoreAuthModuleName);
|
|
@@ -607,10 +611,10 @@ export async function findUserRoles(userId: string, env: Environment): Promise<R
|
|
|
607
611
|
const inst: Instance | undefined = result ? (result[0] as Instance) : undefined;
|
|
608
612
|
if (inst) {
|
|
609
613
|
let roles: Instance[] | undefined = inst.getRelatedInstances('UserRole');
|
|
610
|
-
if (roles
|
|
614
|
+
if (roles === undefined) {
|
|
611
615
|
roles = [];
|
|
612
616
|
}
|
|
613
|
-
if (DefaultRoleInstance
|
|
617
|
+
if (DefaultRoleInstance === undefined) {
|
|
614
618
|
DefaultRoleInstance = makeInstance(
|
|
615
619
|
CoreAuthModuleName,
|
|
616
620
|
'Role',
|
|
@@ -664,7 +668,7 @@ export async function userHasPermissions(
|
|
|
664
668
|
return true;
|
|
665
669
|
}
|
|
666
670
|
let userRoles: string[] | null | undefined = UserRoleCache.get(userId);
|
|
667
|
-
if (userRoles
|
|
671
|
+
if (!userRoles) {
|
|
668
672
|
const roles: any = await findUserRoles(userId, env);
|
|
669
673
|
userRoles = [];
|
|
670
674
|
if (roles) {
|
|
@@ -680,6 +684,7 @@ export async function userHasPermissions(
|
|
|
680
684
|
UserRoleCache.set(userId, userRoles);
|
|
681
685
|
}
|
|
682
686
|
if (
|
|
687
|
+
userRoles &&
|
|
683
688
|
userRoles.find((role: string) => {
|
|
684
689
|
return role === 'admin';
|
|
685
690
|
})
|
|
@@ -692,21 +697,23 @@ export async function userHasPermissions(
|
|
|
692
697
|
perms.has(RbacPermissionFlag.UPDATE),
|
|
693
698
|
perms.has(RbacPermissionFlag.DELETE),
|
|
694
699
|
];
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
if (
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
700
|
+
if (userRoles !== null) {
|
|
701
|
+
for (let i = 0; i < userRoles.length; ++i) {
|
|
702
|
+
const permInsts: RbacPermission[] | undefined = RolePermissionsCache.get(userRoles[i]);
|
|
703
|
+
if (permInsts) {
|
|
704
|
+
if (
|
|
705
|
+
permInsts.find((p: RbacPermission) => {
|
|
706
|
+
return (
|
|
707
|
+
p.resourceFqName == resourceFqName &&
|
|
708
|
+
(c ? isSqlTrue(p.c) : true) &&
|
|
709
|
+
(r ? isSqlTrue(p.r) : true) &&
|
|
710
|
+
(u ? isSqlTrue(p.u) : true) &&
|
|
711
|
+
(d ? isSqlTrue(p.d) : true)
|
|
712
|
+
);
|
|
713
|
+
})
|
|
714
|
+
)
|
|
715
|
+
return true;
|
|
716
|
+
}
|
|
710
717
|
}
|
|
711
718
|
}
|
|
712
719
|
return false;
|
|
@@ -878,6 +885,32 @@ export async function loginUser(
|
|
|
878
885
|
}
|
|
879
886
|
}
|
|
880
887
|
|
|
888
|
+
export async function callbackUser(code: string, env: Environment): Promise<string | object> {
|
|
889
|
+
let result: string | object = '';
|
|
890
|
+
try {
|
|
891
|
+
await fetchAuthImpl().callback(code, env, (r: SessionInfo) => {
|
|
892
|
+
UserRoleCache.set(r.userId, null);
|
|
893
|
+
if (r.idToken && r.accessToken && r.refreshToken) {
|
|
894
|
+
result = {
|
|
895
|
+
id_token: r.idToken,
|
|
896
|
+
access_token: r.accessToken,
|
|
897
|
+
refresh_token: r.refreshToken,
|
|
898
|
+
token_type: 'Bearer',
|
|
899
|
+
expires_in: 3600,
|
|
900
|
+
userId: r.userId,
|
|
901
|
+
sessionId: r.sessionId,
|
|
902
|
+
};
|
|
903
|
+
} else {
|
|
904
|
+
result = `${r.userId}/${r.sessionId}`;
|
|
905
|
+
}
|
|
906
|
+
});
|
|
907
|
+
return result;
|
|
908
|
+
} catch (err: any) {
|
|
909
|
+
logger.error(`Callback failed for ${code}: ${err.message}`);
|
|
910
|
+
throw err;
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
|
|
881
914
|
async function logoutSession(userId: string, sess: Instance, env: Environment): Promise<Result> {
|
|
882
915
|
const sessId = sess.lookup('id');
|
|
883
916
|
const tok = sess.lookup('authToken');
|
|
@@ -1030,7 +1063,7 @@ async function verifySessionToken(token: string, env?: Environment): Promise<Act
|
|
|
1030
1063
|
const f = async () => {
|
|
1031
1064
|
try {
|
|
1032
1065
|
const sess: Instance = await findSession(sessId, env);
|
|
1033
|
-
if (sess
|
|
1066
|
+
if (sess !== undefined) {
|
|
1034
1067
|
await fetchAuthImpl().verifyToken(sess.lookup('authToken'), env);
|
|
1035
1068
|
return { sessionId: sessId, userId: parts[0] };
|
|
1036
1069
|
} else {
|
|
@@ -1194,7 +1227,8 @@ export function requireAuth(moduleName: string, eventName: string): boolean {
|
|
|
1194
1227
|
eventName == 'forgotPassword' ||
|
|
1195
1228
|
eventName == 'confirmForgotPassword' ||
|
|
1196
1229
|
eventName == 'refreshToken' ||
|
|
1197
|
-
eventName == 'acceptInvitation'
|
|
1230
|
+
eventName == 'acceptInvitation' ||
|
|
1231
|
+
eventName == 'callback');
|
|
1198
1232
|
return !f;
|
|
1199
1233
|
} else {
|
|
1200
1234
|
return false;
|
|
@@ -84,7 +84,7 @@ export function setTimerRunning(timerInst: Instance) {
|
|
|
84
84
|
export async function maybeCancelTimer(name: string, timer: NodeJS.Timeout, env: Environment) {
|
|
85
85
|
await parseAndEvaluateStatement(`{agentlang/timer {name? "${name}"}}`, undefined, env).then(
|
|
86
86
|
(result: any) => {
|
|
87
|
-
if (result
|
|
87
|
+
if (result === null || (result instanceof Array && result.length == 0)) {
|
|
88
88
|
clearInterval(timer);
|
|
89
89
|
}
|
|
90
90
|
}
|
package/src/runtime/openapi.ts
CHANGED
|
@@ -15,7 +15,7 @@ export async function registerOpenApiModule(
|
|
|
15
15
|
moduleName: string,
|
|
16
16
|
handle: OpenApiHandle
|
|
17
17
|
): Promise<string> {
|
|
18
|
-
if (OpenApiModules
|
|
18
|
+
if (OpenApiModules === undefined) {
|
|
19
19
|
OpenApiModules = new Map();
|
|
20
20
|
}
|
|
21
21
|
const m = new Map(Object.entries(handle.client));
|
|
@@ -37,7 +37,7 @@ export async function registerOpenApiModule(
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
export function isOpenApiModule(moduleName: string): boolean {
|
|
40
|
-
return OpenApiModules
|
|
40
|
+
return OpenApiModules !== undefined && OpenApiModules.has(moduleName);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
export type OpenApiArgs = {
|
package/src/runtime/relgraph.ts
CHANGED
|
@@ -107,7 +107,7 @@ export function buildGraph(moduleName: string): RelationshipGraph {
|
|
|
107
107
|
}
|
|
108
108
|
});
|
|
109
109
|
});
|
|
110
|
-
if (localMod
|
|
110
|
+
if (localMod === undefined) {
|
|
111
111
|
throw new Error(`Failed to find module ${moduleName}`);
|
|
112
112
|
}
|
|
113
113
|
const remEnts: Set<string> = new Set();
|
|
@@ -5,8 +5,8 @@ export class ResolverAuthInfo {
|
|
|
5
5
|
|
|
6
6
|
constructor(userId: string, readForUpdate?: boolean, readForDelete?: boolean) {
|
|
7
7
|
this.userId = userId;
|
|
8
|
-
if (readForUpdate
|
|
9
|
-
if (readForDelete
|
|
8
|
+
if (readForUpdate !== undefined) this.readForUpdate = readForUpdate;
|
|
9
|
+
if (readForDelete !== undefined) this.readForDelete = readForDelete;
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
|
|
@@ -215,7 +215,7 @@ export class Resolver {
|
|
|
215
215
|
}
|
|
216
216
|
|
|
217
217
|
public async onSubscription(result: any, callPostCrudEvent: boolean = false): Promise<any> {
|
|
218
|
-
if (result
|
|
218
|
+
if (result !== undefined) {
|
|
219
219
|
try {
|
|
220
220
|
if (callPostCrudEvent) {
|
|
221
221
|
const inst = result as Instance;
|
|
@@ -24,7 +24,7 @@ export function getResolverNameForPath(fqEntryName: string): string | undefined
|
|
|
24
24
|
|
|
25
25
|
export function getResolver(fqEntryName: string): Resolver {
|
|
26
26
|
const resName: string | undefined = resolverPathMappings.get(fqEntryName);
|
|
27
|
-
if (resName
|
|
27
|
+
if (resName !== undefined) {
|
|
28
28
|
const f: MakeResolver | undefined = resolverDb.get(resName);
|
|
29
29
|
if (f) return f();
|
|
30
30
|
}
|
|
@@ -48,7 +48,7 @@ export class DbContext {
|
|
|
48
48
|
this.authInfo = authInfo;
|
|
49
49
|
this.activeEnv = activeEnv;
|
|
50
50
|
this.txnId = txnId;
|
|
51
|
-
if (inKernelMode
|
|
51
|
+
if (inKernelMode !== undefined) {
|
|
52
52
|
this.inKernelMode = inKernelMode;
|
|
53
53
|
}
|
|
54
54
|
this.rbacRules = rbacRules;
|
|
@@ -56,7 +56,7 @@ export class DbContext {
|
|
|
56
56
|
private static GlobalDbContext: DbContext | undefined;
|
|
57
57
|
|
|
58
58
|
static getGlobalContext(): DbContext {
|
|
59
|
-
if (DbContext.GlobalDbContext
|
|
59
|
+
if (DbContext.GlobalDbContext === undefined) {
|
|
60
60
|
DbContext.GlobalDbContext = new DbContext(
|
|
61
61
|
'',
|
|
62
62
|
DefaultAuthInfo,
|
|
@@ -282,7 +282,7 @@ export function isVectorStoreSupported(): boolean {
|
|
|
282
282
|
}
|
|
283
283
|
|
|
284
284
|
export async function initDatabase(config: DatabaseConfig | undefined) {
|
|
285
|
-
if (defaultDataSource
|
|
285
|
+
if (defaultDataSource === undefined) {
|
|
286
286
|
const mkds = getDsFunction(config);
|
|
287
287
|
if (mkds) {
|
|
288
288
|
const ormScm = modulesAsOrmSchema();
|
|
@@ -405,7 +405,7 @@ export async function vectorStoreSearchEntryExists(
|
|
|
405
405
|
const qb = getDatasourceForTransaction(ctx.txnId).getRepository(tableName).manager;
|
|
406
406
|
const vecTableName = tableName + VectorSuffix;
|
|
407
407
|
const result: any[] = await qb.query(`select id from ${vecTableName} where id = $1`, [id]);
|
|
408
|
-
return result
|
|
408
|
+
return result !== null && result.length > 0;
|
|
409
409
|
} catch (err: any) {
|
|
410
410
|
logger.error(`Vector store search failed - ${err}`);
|
|
411
411
|
}
|
|
@@ -448,7 +448,7 @@ async function checkUserPerm(
|
|
|
448
448
|
default:
|
|
449
449
|
f = undefined;
|
|
450
450
|
}
|
|
451
|
-
if (f
|
|
451
|
+
if (f !== undefined) {
|
|
452
452
|
hasPerm = await f(userId, ctx.resourceFqName, ctx.activeEnv);
|
|
453
453
|
}
|
|
454
454
|
}
|
|
@@ -642,7 +642,7 @@ async function isOwner(parentName: string, instPath: string, ctx: DbContext): Pr
|
|
|
642
642
|
} catch (reason: any) {
|
|
643
643
|
logger.error(`Failed to check ownership on parent ${parentName} - ${reason}`);
|
|
644
644
|
}
|
|
645
|
-
if (result
|
|
645
|
+
if (result === undefined || result.length === 0) {
|
|
646
646
|
return false;
|
|
647
647
|
}
|
|
648
648
|
return true;
|
|
@@ -760,7 +760,7 @@ export async function getMany(
|
|
|
760
760
|
const alias: string = tableName.toLowerCase();
|
|
761
761
|
const queryStr: string = withNotDeletedClause(
|
|
762
762
|
alias,
|
|
763
|
-
queryObj
|
|
763
|
+
queryObj !== undefined ? objectToWhereClause(queryObj, queryVals, alias) : ''
|
|
764
764
|
);
|
|
765
765
|
let ownersJoinCond: string[] | undefined;
|
|
766
766
|
let ot: string = '';
|
|
@@ -819,7 +819,7 @@ export async function getManyByJoin(
|
|
|
819
819
|
const alias: string = tableName.toLowerCase();
|
|
820
820
|
const queryStr: string = withNotDeletedClause(
|
|
821
821
|
alias,
|
|
822
|
-
queryObj
|
|
822
|
+
queryObj !== undefined ? objectToRawWhereClause(queryObj, queryVals, alias) : ''
|
|
823
823
|
);
|
|
824
824
|
let ot: string = '';
|
|
825
825
|
let otAlias: string = '';
|
|
@@ -928,7 +928,7 @@ export async function getAllConnected(
|
|
|
928
928
|
const transactionsDb: Map<string, QueryRunner> = new Map<string, QueryRunner>();
|
|
929
929
|
|
|
930
930
|
export async function startDbTransaction(): Promise<string> {
|
|
931
|
-
if (defaultDataSource
|
|
931
|
+
if (defaultDataSource !== undefined) {
|
|
932
932
|
const queryRunner = defaultDataSource.createQueryRunner();
|
|
933
933
|
await queryRunner.startTransaction();
|
|
934
934
|
const txnId: string = crypto.randomUUID();
|
|
@@ -942,13 +942,13 @@ export async function startDbTransaction(): Promise<string> {
|
|
|
942
942
|
function getDatasourceForTransaction(txnId: string | undefined): DataSource | EntityManager {
|
|
943
943
|
if (txnId) {
|
|
944
944
|
const qr: QueryRunner | undefined = transactionsDb.get(txnId);
|
|
945
|
-
if (qr
|
|
945
|
+
if (qr === undefined) {
|
|
946
946
|
throw new Error(`Transaction not found - ${txnId}`);
|
|
947
947
|
} else {
|
|
948
948
|
return qr.manager;
|
|
949
949
|
}
|
|
950
950
|
} else {
|
|
951
|
-
if (defaultDataSource
|
|
951
|
+
if (defaultDataSource !== undefined) return defaultDataSource;
|
|
952
952
|
else throw new Error('No default datasource is initialized');
|
|
953
953
|
}
|
|
954
954
|
}
|
|
@@ -44,7 +44,7 @@ import { logger } from '../../logger.js';
|
|
|
44
44
|
|
|
45
45
|
function maybeFindIdAttributeName(inst: Instance): string | undefined {
|
|
46
46
|
const attrEntry: AttributeEntry | undefined = findIdAttribute(inst);
|
|
47
|
-
if (attrEntry
|
|
47
|
+
if (attrEntry !== undefined) {
|
|
48
48
|
return attrEntry.name;
|
|
49
49
|
}
|
|
50
50
|
return undefined;
|
|
@@ -95,11 +95,11 @@ export class SqlDbResolver extends Resolver {
|
|
|
95
95
|
ensureOneToOneAttributes(inst);
|
|
96
96
|
const attrs: InstanceAttributes = inst.attributes;
|
|
97
97
|
const idAttrVal: any = idAttrName ? attrs.get(idAttrName) : crypto.randomUUID();
|
|
98
|
-
if (idAttrVal
|
|
98
|
+
if (idAttrVal !== undefined) {
|
|
99
99
|
const pp: string | undefined = attrs.get(PathAttributeName);
|
|
100
100
|
const n: string = `${inst.moduleName}/${inst.name}`;
|
|
101
101
|
let p: string = '';
|
|
102
|
-
if (pp
|
|
102
|
+
if (pp !== undefined) p = `${pp}/${escapeFqName(n)}/${idAttrVal}`;
|
|
103
103
|
else p = `${n.replace('/', '$')}/${idAttrVal}`;
|
|
104
104
|
attrs.set(PathAttributeName, p);
|
|
105
105
|
}
|
|
@@ -186,7 +186,7 @@ export class SqlDbResolver extends Resolver {
|
|
|
186
186
|
target: Instance | Instance[],
|
|
187
187
|
purge: boolean
|
|
188
188
|
): Promise<Instance[] | Instance> {
|
|
189
|
-
if (target
|
|
189
|
+
if (target !== null) {
|
|
190
190
|
if (target instanceof Array) {
|
|
191
191
|
for (let i = 0; i < target.length; ++i) {
|
|
192
192
|
await this.deleteInstanceHelper(target[i], purge);
|
package/src/runtime/util.ts
CHANGED
|
@@ -50,11 +50,11 @@ export function isStringNumeric(str: string): boolean {
|
|
|
50
50
|
type MaybeString = string | undefined;
|
|
51
51
|
|
|
52
52
|
export function isString(s: MaybeString): boolean {
|
|
53
|
-
return s
|
|
53
|
+
return s !== undefined && typeof s === 'string';
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
function asString(s: MaybeString): string {
|
|
57
|
-
if (s
|
|
57
|
+
if (s === undefined) return '';
|
|
58
58
|
else return s;
|
|
59
59
|
}
|
|
60
60
|
|
|
@@ -351,7 +351,7 @@ export function findAllPrePostTriggerSchema(
|
|
|
351
351
|
for (let i = 0; i < scm.extras.length; ++i) {
|
|
352
352
|
const rex: RecordExtraDefinition = scm.extras[i];
|
|
353
353
|
if (rex.prePost) {
|
|
354
|
-
if (result
|
|
354
|
+
if (result === undefined) {
|
|
355
355
|
result = new Array<PrePostTriggerDefinition>();
|
|
356
356
|
}
|
|
357
357
|
result.push(rex.prePost);
|
|
@@ -372,7 +372,7 @@ export enum CrudType {
|
|
|
372
372
|
|
|
373
373
|
export function asCrudType(s: string): CrudType {
|
|
374
374
|
const r: CrudType | undefined = CrudType[s.toUpperCase() as keyof typeof CrudType];
|
|
375
|
-
if (r
|
|
375
|
+
if (r === undefined) {
|
|
376
376
|
throw new Error(`${s} does not represent a valid CrudType`);
|
|
377
377
|
}
|
|
378
378
|
return r;
|
|
@@ -440,7 +440,7 @@ function maybeExtractModuleName(n: string, moduleName?: string | undefined): str
|
|
|
440
440
|
if (i > 0) {
|
|
441
441
|
return n.substring(0, i);
|
|
442
442
|
}
|
|
443
|
-
if (moduleName
|
|
443
|
+
if (moduleName === undefined) {
|
|
444
444
|
throw new Error(`Failed to extract module-name from ${n}`);
|
|
445
445
|
}
|
|
446
446
|
return moduleName;
|
package/src/utils/runtime.ts
CHANGED
|
@@ -2,7 +2,7 @@ export let chalk: any;
|
|
|
2
2
|
|
|
3
3
|
// Environment detection
|
|
4
4
|
export const isNodeEnv =
|
|
5
|
-
typeof process !== 'undefined' && process.versions
|
|
5
|
+
typeof process !== 'undefined' && process.versions !== null && process.versions.node !== null;
|
|
6
6
|
|
|
7
7
|
if (isNodeEnv) {
|
|
8
8
|
// Only import Node.js modules in Node environment
|
|
@@ -15,7 +15,7 @@ if (isNodeEnv) {
|
|
|
15
15
|
export function isExecGraphEnabled(): boolean {
|
|
16
16
|
if (isNodeEnv) {
|
|
17
17
|
const flag = process.env['AL_EXEC_GRAPH_ENABLED'];
|
|
18
|
-
if (flag
|
|
18
|
+
if (flag !== undefined && flag === 'false') {
|
|
19
19
|
return false;
|
|
20
20
|
}
|
|
21
21
|
}
|