Dimava
Dimava
Aarktype
Created by Dimava on 10/29/2024 in #questions
Compiling scope to interfaces
Okay will do that But so, How do I cast scope({ a }) to type(a).infer? I guess that's the most sensible question I can ask
38 replies
Aarktype
Created by Dimava on 10/29/2024 in #questions
Compiling scope to interfaces
Can I "clean" defintions by casting them all to type.cast<unbranded> so they don't revalidate?
38 replies
Aarktype
Created by Dimava on 10/29/2024 in #questions
Compiling scope to interfaces
but I feel like validating them 5+ times takes time
38 replies
Aarktype
Created by Dimava on 10/29/2024 in #questions
Compiling scope to interfaces
definitions work fine in d.ts
38 replies
Aarktype
Created by Dimava on 10/29/2024 in #questions
Compiling scope to interfaces
tbh I do like the g: "loose" hack to variate the behaviour
38 replies
Aarktype
Created by Dimava on 10/29/2024 in #questions
Compiling scope to interfaces
import { scope, type } from 'arktype'
import { $def } from './brands'

export const $$_def = scope.define({
...$def,
g: '"loose"',

MetricDictionary: 'Dictionary<Metric, g>',
Metric: {
value: 'metricId',
label: 'string>0',
cats: 'Sorted<categoryId[], g>',
metricType: 'metricType',
description: 'optionalDescription',
},
import { scope, type } from 'arktype'
import { $def } from './brands'

export const $$_def = scope.define({
...$def,
g: '"loose"',

MetricDictionary: 'Dictionary<Metric, g>',
Metric: {
value: 'metricId',
label: 'string>0',
cats: 'Sorted<categoryId[], g>',
metricType: 'metricType',
description: 'optionalDescription',
},
38 replies
Aarktype
Created by Dimava on 10/29/2024 in #questions
Compiling scope to interfaces
This is what's all that is based upon
38 replies
Aarktype
Created by Dimava on 10/29/2024 in #questions
Compiling scope to interfaces
export interface $$def extends $def,
Replace<Omit<typeof $$_def, keyof ct.$def | 'g'>, {
Metric: type.cast<Metric>
Period: type.cast<Period>
Cost: type.cast<Cost>
Category: type.cast<Category>
Parameter: type.cast<Parameter>
Account: type.cast<Account>
CostCente: type.cast<CostCenter>
Project: type.cast<Project>
Service: type.cast<Service>
Vectors: type.cast<Vectors>
ABCRecord: type.cast<ABCRecord>
}> { }

type $$$_def = typeof $$$_def
export interface Cycle extends InferFace<$$$_def, 'Cycle'> { }
type $$$_def1 = Replace<typeof $$$_def, { Cycle: type.cast<Cycle> }>
export interface ResourceBase extends InferFace<$$$_def1, 'ResourceBase'> { }
export interface AggregateResource extends Replace<ResourceBase, InferFace<$$$_def1, 'AggregateResourceVariant'>> { }
export interface RegularResource extends Replace<ResourceBase, InferFace<$$$_def1, 'RegularResourceVariant'>> { }
export type Resource = AggregateResource | RegularResource

type $$$_def2 = Replace<typeof $$$_def, { Cycle: type.cast<Cycle>, Resource: type.cast<Resource> }>

export interface Model extends InferFace<$$$_def2, 'Model'> { }

export type $$$def = Replace<typeof $$$_def, { Cycle: type.cast<Cycle>, Resource: type.cast<Resource>, Model: type.cast<Model> }>
}
export interface $$def extends $def,
Replace<Omit<typeof $$_def, keyof ct.$def | 'g'>, {
Metric: type.cast<Metric>
Period: type.cast<Period>
Cost: type.cast<Cost>
Category: type.cast<Category>
Parameter: type.cast<Parameter>
Account: type.cast<Account>
CostCente: type.cast<CostCenter>
Project: type.cast<Project>
Service: type.cast<Service>
Vectors: type.cast<Vectors>
ABCRecord: type.cast<ABCRecord>
}> { }

type $$$_def = typeof $$$_def
export interface Cycle extends InferFace<$$$_def, 'Cycle'> { }
type $$$_def1 = Replace<typeof $$$_def, { Cycle: type.cast<Cycle> }>
export interface ResourceBase extends InferFace<$$$_def1, 'ResourceBase'> { }
export interface AggregateResource extends Replace<ResourceBase, InferFace<$$$_def1, 'AggregateResourceVariant'>> { }
export interface RegularResource extends Replace<ResourceBase, InferFace<$$$_def1, 'RegularResourceVariant'>> { }
export type Resource = AggregateResource | RegularResource

type $$$_def2 = Replace<typeof $$$_def, { Cycle: type.cast<Cycle>, Resource: type.cast<Resource> }>

export interface Model extends InferFace<$$$_def2, 'Model'> { }

export type $$$def = Replace<typeof $$$_def, { Cycle: type.cast<Cycle>, Resource: type.cast<Resource>, Model: type.cast<Model> }>
}
This is way #2
38 replies
Aarktype
Created by Dimava on 10/29/2024 in #questions
Compiling scope to interfaces
That's the way #1 and it did work fine
38 replies
Aarktype
Created by Dimava on 10/29/2024 in #questions
Compiling scope to interfaces
export interface Cycle extends Identity<typeof mod.Cycle.infer> { }
export interface ResourceBase extends Replace<typeof mod.ResourceBase.infer, { actcycles: Cycle[], budcycles: Cycle[] }> { }

export interface AggregateResource extends Replace<ResourceBase, Identity<typeof mod.AggregateResourceVariant.infer>> {}
export interface RegularResource extends Replace<ResourceBase, Identity<typeof mod.RegularResourceVariant.infer>> {}
export type Resource = AggregateResource | RegularResource

export interface Model extends Replace<typeof mod.Model.infer, { resources: Resource[] }> {}
export interface Cycle extends Identity<typeof mod.Cycle.infer> { }
export interface ResourceBase extends Replace<typeof mod.ResourceBase.infer, { actcycles: Cycle[], budcycles: Cycle[] }> { }

export interface AggregateResource extends Replace<ResourceBase, Identity<typeof mod.AggregateResourceVariant.infer>> {}
export interface RegularResource extends Replace<ResourceBase, Identity<typeof mod.RegularResourceVariant.infer>> {}
export type Resource = AggregateResource | RegularResource

export interface Model extends Replace<typeof mod.Model.infer, { resources: Resource[] }> {}
38 replies
Aarktype
Created by Dimava on 10/29/2024 in #questions
Compiling scope to interfaces
I do have everything working already so I guess I should just show that to start
38 replies
Aarktype
Created by Dimava on 10/29/2024 in #questions
Compiling scope to interfaces
You didn't get the question what's the equivalent of type(a).infer in scope({a})
38 replies
Aarktype
Created by Dimava on 10/29/2024 in #questions
Compiling scope to interfaces
Nah I mean literally like in type example above
38 replies
Aarktype
Created by Dimava on 10/29/2024 in #questions
Compiling scope to interfaces
How do I infer from scopes?
38 replies
Aarktype
Created by Dimava on 10/29/2024 in #questions
Compiling scope to interfaces
Yep, but I want scopes 😭
38 replies
Aarktype
Created by Dimava on 10/29/2024 in #questions
Compiling scope to interfaces
There may be some obvious api you have I missed
38 replies
Aarktype
Created by Dimava on 10/29/2024 in #questions
Compiling scope to interfaces
Hmm, or now when I get to PC
38 replies
Aarktype
Created by Dimava on 10/29/2024 in #questions
Compiling scope to interfaces
Should I ping you with some examples tomorrow?
38 replies
Aarktype
Created by Dimava on 10/29/2024 in #questions
Compiling scope to interfaces
I'm currently slicing scope definitions to non-recursive parts But it causes long compilation times so I'm digging how to do it efficiently
38 replies
Aarktype
Created by Dimava on 10/29/2024 in #questions
Compiling scope to interfaces
Some of the types include whole inline scope in definition
38 replies