opacacms 0.1.4 → 0.1.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.
@@ -1,5 +1,11 @@
1
1
  import type { Collection as BaseCollection, IconName } from "../types";
2
2
  import type { AccessRules, InferFields } from "./infer";
3
+ /**
4
+ * Factory for creating Collections.
5
+ */
6
+ export declare const Collection: {
7
+ create: (slug: string) => CollectionBuilder<{}>;
8
+ };
3
9
  /**
4
10
  * The Fluent API Collection Builder.
5
11
  */
@@ -95,6 +101,3 @@ export declare class CollectionBuilder<TFields extends Record<string, any> = {}>
95
101
  */
96
102
  build(): BaseCollection;
97
103
  }
98
- export declare const Collection: {
99
- create: (slug: string) => CollectionBuilder<{}>;
100
- };
@@ -1,4 +1,29 @@
1
1
  import { FieldBuilder } from "./base";
2
+ /**
3
+ * The Field Factory object containing methods to instantiate specific field builders.
4
+ * Defined at the top to avoid TDZ (Temporal Dead Zone) during module evaluation.
5
+ */
6
+ export declare const Field: {
7
+ text: <N extends string>(name: N) => TextFieldBuilder<N>;
8
+ slug: <N extends string>(name: N) => SlugFieldBuilder<N>;
9
+ textarea: <N extends string>(name: N) => TextAreaFieldBuilder<N>;
10
+ number: <N extends string>(name: N) => NumberFieldBuilder<N>;
11
+ boolean: <N extends string>(name: N) => BooleanFieldBuilder<N>;
12
+ date: <N extends string>(name: N) => DateFieldBuilder<N>;
13
+ select: <N extends string>(name: N) => SelectFieldBuilder<N>;
14
+ radio: <N extends string>(name: N) => RadioFieldBuilder<N>;
15
+ richText: <N extends string>(name: N) => RichTextFieldBuilder<N>;
16
+ relationship: <N extends string>(name: N) => RelationshipFieldBuilder<N>;
17
+ join: <N extends string>(name: N) => JoinFieldBuilder<N>;
18
+ file: <N extends string>(name: N) => FileFieldBuilder<N>;
19
+ array: <N extends string>(name: N) => ArrayFieldBuilder<N, any[]>;
20
+ group: <N extends string, TSub extends readonly FieldBuilder<any, any, any, any>[]>(name: N, fields?: TSub) => GroupFieldBuilder<N, any, TSub>;
21
+ tabs: () => TabsFieldBuilder<[]>;
22
+ collapsible: <N extends string, S extends readonly FieldBuilder<any, any, any, any>[]>(fields?: S) => CollapsibleFieldBuilder<ExtractNames<S>, S>;
23
+ row: <S extends readonly FieldBuilder<any, any, any, any>[]>(fields?: S) => RowFieldBuilder<S>;
24
+ blocks: <N extends string, TSub extends readonly BlockBuilder<any, any, any>[]>(name: N, ...blocks: TSub) => BlocksFieldBuilder<N, TSub>;
25
+ block: <N extends string>(slug: N) => BlockBuilder<N, string, any[]>;
26
+ };
2
27
  export declare class TextFieldBuilder<TName extends string> extends FieldBuilder<"text", TName, string> {
3
28
  constructor(name: TName);
4
29
  }
@@ -93,43 +118,9 @@ export declare class BlockBuilder<TSlug extends string, TNames extends string =
93
118
  fields<NewSub extends readonly FieldBuilder<any, any, any, any>[]>(...fields: NewSub): BlockBuilder<TSlug, ExtractNames<NewSub>, NewSub>;
94
119
  build(): Record<string, any>;
95
120
  }
96
- export declare class VirtualFieldBuilder<TName extends string, TData = any> extends FieldBuilder<"virtual", TName, any> {
97
- constructor(name: TName);
98
- resolve(fn: (args: {
99
- data: TData;
100
- req: any;
101
- user: any;
102
- session: any;
103
- apiKey?: any;
104
- }) => any | Promise<any>): this;
105
- returnType(type: "string" | "number" | "boolean" | "json"): this;
106
- }
121
+ export { VirtualFieldBuilder } from "./virtual";
107
122
  export declare class BlocksFieldBuilder<TName extends string, TBlocks extends readonly any[] = any[]> extends FieldBuilder<"blocks", TName, any[], TBlocks> {
108
123
  constructor(name: TName);
109
124
  blocks<NewBlocks extends readonly BlockBuilder<any, any, any>[]>(...blocks: NewBlocks): BlocksFieldBuilder<TName, NewBlocks>;
110
125
  }
111
- /**
112
- * The Field Factory object containing methods to instantiate specific field builders.
113
- */
114
- export declare const Field: {
115
- text: <N extends string>(name: N) => TextFieldBuilder<N>;
116
- slug: <N extends string>(name: N) => SlugFieldBuilder<N>;
117
- textarea: <N extends string>(name: N) => TextAreaFieldBuilder<N>;
118
- number: <N extends string>(name: N) => NumberFieldBuilder<N>;
119
- boolean: <N extends string>(name: N) => BooleanFieldBuilder<N>;
120
- date: <N extends string>(name: N) => DateFieldBuilder<N>;
121
- select: <N extends string>(name: N) => SelectFieldBuilder<N>;
122
- radio: <N extends string>(name: N) => RadioFieldBuilder<N>;
123
- richText: <N extends string>(name: N) => RichTextFieldBuilder<N>;
124
- relationship: <N extends string>(name: N) => RelationshipFieldBuilder<N>;
125
- join: <N extends string>(name: N) => JoinFieldBuilder<N>;
126
- file: <N extends string>(name: N) => FileFieldBuilder<N>;
127
- array: <N extends string>(name: N) => ArrayFieldBuilder<N, any[]>;
128
- group: <N extends string, TSub extends readonly FieldBuilder<any, any, any, any>[]>(name: N, fields?: TSub) => GroupFieldBuilder<N, any, TSub>;
129
- tabs: () => TabsFieldBuilder<[]>;
130
- collapsible: <N extends string, S extends readonly FieldBuilder<any, any, any, any>[]>(fields?: S) => CollapsibleFieldBuilder<ExtractNames<S>, S>;
131
- row: <S extends readonly FieldBuilder<any, any, any, any>[]>(fields?: S) => RowFieldBuilder<S>;
132
- blocks: <N extends string, TSub extends readonly BlockBuilder<any, any, any>[]>(name: N, ...blocks: TSub) => BlocksFieldBuilder<N, TSub>;
133
- block: <N extends string>(slug: N) => BlockBuilder<N, string, any[]>;
134
- };
135
126
  export * from "./base";
@@ -0,0 +1,22 @@
1
+ import { FieldBuilder } from "./base";
2
+ /**
3
+ * A builder for virtual/computed fields.
4
+ * These fields are not stored in the database but are resolved at runtime.
5
+ */
6
+ export declare class VirtualFieldBuilder<TName extends string, TData = any> extends FieldBuilder<"virtual", TName, any> {
7
+ constructor(name: TName);
8
+ /**
9
+ * Defines the resolver function for this virtual field.
10
+ */
11
+ resolve(fn: (args: {
12
+ data: TData;
13
+ req: any;
14
+ user: any;
15
+ session: any;
16
+ apiKey?: any;
17
+ }) => any | Promise<any>): this;
18
+ /**
19
+ * Sets the return type hint for the API/Client.
20
+ */
21
+ returnType(type: "string" | "number" | "boolean" | "json"): this;
22
+ }
@@ -1,7 +1,13 @@
1
1
  import type { AccessConfig, Global as GlobalType, IconName } from "../types";
2
- import { type FieldBuilder } from "./fields";
2
+ import { type FieldBuilder } from "./fields/base";
3
3
  import type { InferFields } from "./infer";
4
4
  export type Global = GlobalType;
5
+ /**
6
+ * Singleton factory for creating Globals.
7
+ */
8
+ export declare const Global: {
9
+ create: (slug: string) => GlobalBuilder<{}>;
10
+ };
5
11
  /**
6
12
  * A Fluent API Builder for defining OpacaCMS Globals.
7
13
  */
@@ -74,9 +80,3 @@ export declare class GlobalBuilder<TFields extends Record<string, any> = {}> {
74
80
  */
75
81
  build(): Global;
76
82
  }
77
- /**
78
- * Singleton factory for creating Globals.
79
- */
80
- export declare const Global: {
81
- create: (slug: string) => GlobalBuilder<{}>;
82
- };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opacacms",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "sideEffects": false,
5
5
  "scripts": {
6
6
  "build": "bun run ../../scripts/build.ts && tsc --emitDeclarationOnly",