adonis-atlas 0.1.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.
Files changed (39) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +150 -0
  3. package/build/chunk-7QVYU63E.js +7 -0
  4. package/build/chunk-7QVYU63E.js.map +1 -0
  5. package/build/client/app.js +20 -0
  6. package/build/client/app.js.map +1 -0
  7. package/build/client/boot.js +23 -0
  8. package/build/client/boot.js.map +1 -0
  9. package/build/client/resources/components/DataTable.vue +103 -0
  10. package/build/client/resources/components/FormField.vue +40 -0
  11. package/build/client/resources/components/Layout.vue +68 -0
  12. package/build/client/resources/components/Pagination.vue +60 -0
  13. package/build/client/resources/components/SearchBar.vue +41 -0
  14. package/build/client/resources/components/fields/BooleanField.vue +26 -0
  15. package/build/client/resources/components/fields/DateTimeField.vue +26 -0
  16. package/build/client/resources/components/fields/EmailField.vue +27 -0
  17. package/build/client/resources/components/fields/NumberField.vue +27 -0
  18. package/build/client/resources/components/fields/PasswordField.vue +28 -0
  19. package/build/client/resources/components/fields/TextField.vue +27 -0
  20. package/build/client/resources/css/atlas.css +662 -0
  21. package/build/client/resources/pages/atlas/Create.vue +132 -0
  22. package/build/client/resources/pages/atlas/Edit.vue +145 -0
  23. package/build/client/resources/pages/atlas/Index.vue +138 -0
  24. package/build/commands/main.js +9 -0
  25. package/build/commands/main.js.map +1 -0
  26. package/build/commands/make_resource.js +42 -0
  27. package/build/commands/make_resource.js.map +1 -0
  28. package/build/configure.js +17 -0
  29. package/build/configure.js.map +1 -0
  30. package/build/index.js +29 -0
  31. package/build/index.js.map +1 -0
  32. package/build/providers/atlas_provider.js +56 -0
  33. package/build/providers/atlas_provider.js.map +1 -0
  34. package/build/stubs/config.stub +18 -0
  35. package/build/stubs/resource.stub +25 -0
  36. package/package.json +81 -0
  37. package/stubs/config.stub +18 -0
  38. package/stubs/main.ts +3 -0
  39. package/stubs/resource.stub +25 -0
@@ -0,0 +1,132 @@
1
+ <script setup lang="ts">
2
+ import { router, Link } from '@inertiajs/vue3'
3
+ import { reactive, ref } from 'vue'
4
+ import '../../css/atlas.css'
5
+ import Layout from '../../components/Layout.vue'
6
+ import FormField from '../../components/FormField.vue'
7
+
8
+ interface FieldDef {
9
+ name: string
10
+ label: string
11
+ component: string
12
+ rules: string[]
13
+ value?: any
14
+ }
15
+
16
+ const props = defineProps<{
17
+ resource: { title: string; uriKey: string }
18
+ fields: FieldDef[]
19
+ navigation: { label: string; uriKey: string }[]
20
+ rootUrl?: string
21
+ }>()
22
+
23
+ // Build form data from field definitions
24
+ const formData = reactive<Record<string, any>>(
25
+ Object.fromEntries(
26
+ props.fields
27
+ .filter((f) => f.name !== 'id' && f.name !== 'createdAt' && f.name !== 'updatedAt')
28
+ .map((f) => [f.name, f.component === 'BooleanField' ? false : ''])
29
+ )
30
+ )
31
+
32
+ const errors = ref<Record<string, string>>({})
33
+ const submitting = ref(false)
34
+ const toast = ref<{ message: string; type: 'success' | 'error' } | null>(null)
35
+
36
+ function showToast(message: string, type: 'success' | 'error' = 'success') {
37
+ toast.value = { message, type }
38
+ setTimeout(() => { toast.value = null }, 3000)
39
+ }
40
+
41
+ // Fields that should appear in the form (exclude auto-generated ones)
42
+ const formFields = props.fields.filter(
43
+ (f) => f.name !== 'id' && f.name !== 'createdAt' && f.name !== 'updatedAt'
44
+ )
45
+
46
+ async function submit() {
47
+ submitting.value = true
48
+ errors.value = {}
49
+
50
+ try {
51
+ const apiBase = props.rootUrl ? `${props.rootUrl}/api` : '/atlas/api'
52
+ const response = await fetch(`${apiBase}/${props.resource.uriKey}`, {
53
+ method: 'POST',
54
+ headers: {
55
+ 'Content-Type': 'application/json',
56
+ 'Accept': 'application/json',
57
+ },
58
+ body: JSON.stringify(formData),
59
+ })
60
+
61
+ const body = await response.json()
62
+
63
+ if (!response.ok) {
64
+ if (body.errors) {
65
+ // VineJS validation errors
66
+ for (const err of body.errors) {
67
+ errors.value[err.field] = err.message
68
+ }
69
+ } else {
70
+ showToast(body.message || 'Failed to create', 'error')
71
+ }
72
+ return
73
+ }
74
+
75
+ showToast(`${props.resource.title} created successfully`)
76
+ setTimeout(() => {
77
+ router.get(`${props.rootUrl || '/atlas'}/${props.resource.uriKey}`)
78
+ }, 800)
79
+ } catch {
80
+ showToast('An unexpected error occurred', 'error')
81
+ } finally {
82
+ submitting.value = false
83
+ }
84
+ }
85
+ </script>
86
+
87
+ <template>
88
+ <Layout
89
+ :navigation="navigation"
90
+ :resource-title="resource.title"
91
+ :breadcrumbs="[
92
+ { label: resource.title, href: `${rootUrl || '/atlas'}/${resource.uriKey}` },
93
+ { label: 'Create' },
94
+ ]"
95
+ :root-url="rootUrl"
96
+ >
97
+ <div class="atlas-page-header">
98
+ <h1 class="atlas-page-header__title">Create {{ resource.title }}</h1>
99
+ </div>
100
+
101
+ <div class="atlas-card">
102
+ <div class="atlas-card__body">
103
+ <form class="atlas-form" @submit.prevent="submit">
104
+ <FormField
105
+ v-for="field in formFields"
106
+ :key="field.name"
107
+ :field="field"
108
+ :modelValue="formData[field.name]"
109
+ :error="errors[field.name]"
110
+ @update:modelValue="formData[field.name] = $event"
111
+ />
112
+
113
+ <div class="atlas-form__actions">
114
+ <button type="submit" class="atlas-btn atlas-btn--primary" :disabled="submitting">
115
+ <span v-if="submitting" class="atlas-spinner" />
116
+ {{ submitting ? 'Creating...' : 'Create' }}
117
+ </button>
118
+ <Link :href="`${rootUrl || '/atlas'}/${resource.uriKey}`" class="atlas-btn atlas-btn--secondary">
119
+ Cancel
120
+ </Link>
121
+ </div>
122
+ </form>
123
+ </div>
124
+ </div>
125
+
126
+ <Teleport to="body">
127
+ <div v-if="toast" class="atlas-toast" :class="`atlas-toast--${toast.type}`">
128
+ {{ toast.message }}
129
+ </div>
130
+ </Teleport>
131
+ </Layout>
132
+ </template>
@@ -0,0 +1,145 @@
1
+ <script setup lang="ts">
2
+ import { router, Link } from '@inertiajs/vue3'
3
+ import { reactive, ref } from 'vue'
4
+ import '../../css/atlas.css'
5
+ import Layout from '../../components/Layout.vue'
6
+ import FormField from '../../components/FormField.vue'
7
+
8
+ interface FieldDef {
9
+ name: string
10
+ label: string
11
+ component: string
12
+ rules: string[]
13
+ value?: any
14
+ }
15
+
16
+ const props = defineProps<{
17
+ resource: { title: string; uriKey: string }
18
+ recordId: number | string
19
+ fields: FieldDef[]
20
+ navigation: { label: string; uriKey: string }[]
21
+ rootUrl?: string
22
+ }>()
23
+
24
+ // Fields editable in the form (exclude auto-generated ones)
25
+ const formFields = props.fields.filter(
26
+ (f) => f.name !== 'id' && f.name !== 'createdAt' && f.name !== 'updatedAt'
27
+ )
28
+
29
+ // Pre-fill form data with existing values
30
+ const formData = reactive<Record<string, any>>(
31
+ Object.fromEntries(
32
+ formFields.map((f) => [
33
+ f.name,
34
+ f.component === 'PasswordField' ? '' : (f.value ?? ''),
35
+ ])
36
+ )
37
+ )
38
+
39
+ const errors = ref<Record<string, string>>({})
40
+ const submitting = ref(false)
41
+ const toast = ref<{ message: string; type: 'success' | 'error' } | null>(null)
42
+
43
+ function showToast(message: string, type: 'success' | 'error' = 'success') {
44
+ toast.value = { message, type }
45
+ setTimeout(() => { toast.value = null }, 3000)
46
+ }
47
+
48
+ async function submit() {
49
+ submitting.value = true
50
+ errors.value = {}
51
+
52
+ // Only send fields that have changed (for partial updates)
53
+ const payload: Record<string, any> = {}
54
+ for (const field of formFields) {
55
+ const val = formData[field.name]
56
+ // Skip empty password (means "don't change")
57
+ if (field.component === 'PasswordField' && !val) continue
58
+ payload[field.name] = val
59
+ }
60
+
61
+ try {
62
+ const apiBase = props.rootUrl ? `${props.rootUrl}/api` : '/atlas/api'
63
+ const response = await fetch(
64
+ `${apiBase}/${props.resource.uriKey}/${props.recordId}`,
65
+ {
66
+ method: 'PUT',
67
+ headers: {
68
+ 'Content-Type': 'application/json',
69
+ 'Accept': 'application/json',
70
+ },
71
+ body: JSON.stringify(payload),
72
+ }
73
+ )
74
+
75
+ const body = await response.json()
76
+
77
+ if (!response.ok) {
78
+ if (body.errors) {
79
+ for (const err of body.errors) {
80
+ errors.value[err.field] = err.message
81
+ }
82
+ } else {
83
+ showToast(body.message || 'Failed to update', 'error')
84
+ }
85
+ return
86
+ }
87
+
88
+ showToast(`${props.resource.title} updated successfully`)
89
+ setTimeout(() => {
90
+ router.get(`${props.rootUrl || '/atlas'}/${props.resource.uriKey}`)
91
+ }, 800)
92
+ } catch {
93
+ showToast('An unexpected error occurred', 'error')
94
+ } finally {
95
+ submitting.value = false
96
+ }
97
+ }
98
+ </script>
99
+
100
+ <template>
101
+ <Layout
102
+ :navigation="navigation"
103
+ :resource-title="resource.title"
104
+ :breadcrumbs="[
105
+ { label: resource.title, href: `${rootUrl || '/atlas'}/${resource.uriKey}` },
106
+ { label: `Edit #${recordId}` },
107
+ ]"
108
+ :root-url="rootUrl"
109
+ >
110
+ <div class="atlas-page-header">
111
+ <h1 class="atlas-page-header__title">Edit {{ resource.title }} #{{ recordId }}</h1>
112
+ </div>
113
+
114
+ <div class="atlas-card">
115
+ <div class="atlas-card__body">
116
+ <form class="atlas-form" @submit.prevent="submit">
117
+ <FormField
118
+ v-for="field in formFields"
119
+ :key="field.name"
120
+ :field="field"
121
+ :modelValue="formData[field.name]"
122
+ :error="errors[field.name]"
123
+ @update:modelValue="formData[field.name] = $event"
124
+ />
125
+
126
+ <div class="atlas-form__actions">
127
+ <button type="submit" class="atlas-btn atlas-btn--primary" :disabled="submitting">
128
+ <span v-if="submitting" class="atlas-spinner" />
129
+ {{ submitting ? 'Saving...' : 'Save Changes' }}
130
+ </button>
131
+ <Link :href="`${rootUrl || '/atlas'}/${resource.uriKey}`" class="atlas-btn atlas-btn--secondary">
132
+ Cancel
133
+ </Link>
134
+ </div>
135
+ </form>
136
+ </div>
137
+ </div>
138
+
139
+ <Teleport to="body">
140
+ <div v-if="toast" class="atlas-toast" :class="`atlas-toast--${toast.type}`">
141
+ {{ toast.message }}
142
+ </div>
143
+ </Teleport>
144
+ </Layout>
145
+ </template>
@@ -0,0 +1,138 @@
1
+ <script setup lang="ts">
2
+ import { router, Link } from '@inertiajs/vue3'
3
+ import '../../css/atlas.css'
4
+ import Layout from '../../components/Layout.vue'
5
+ import DataTable from '../../components/DataTable.vue'
6
+ import Pagination from '../../components/Pagination.vue'
7
+ import SearchBar from '../../components/SearchBar.vue'
8
+ import { ref } from 'vue'
9
+
10
+ interface FieldDef {
11
+ name: string
12
+ label: string
13
+ component: string
14
+ sortable: boolean
15
+ value?: any
16
+ }
17
+
18
+ interface Row {
19
+ id: number | string
20
+ fields: FieldDef[]
21
+ }
22
+
23
+ interface Meta {
24
+ total: number
25
+ perPage: number
26
+ currentPage: number
27
+ lastPage: number
28
+ }
29
+
30
+ const props = defineProps<{
31
+ resource: { title: string; uriKey: string }
32
+ data: Row[]
33
+ meta: Meta
34
+ filters: Record<string, string>
35
+ navigation: { label: string; uriKey: string }[]
36
+ rootUrl?: string
37
+ }>()
38
+
39
+ const search = ref(props.filters.search || '')
40
+ const toast = ref<{ message: string; type: 'success' | 'error' } | null>(null)
41
+
42
+ function showToast(message: string, type: 'success' | 'error' = 'success') {
43
+ toast.value = { message, type }
44
+ setTimeout(() => { toast.value = null }, 3000)
45
+ }
46
+
47
+ function navigate(params: Record<string, any>) {
48
+ const query = { ...props.filters, ...params }
49
+ // Remove empty values
50
+ Object.keys(query).forEach((k) => {
51
+ if (!query[k]) delete query[k]
52
+ })
53
+ router.get(`${props.rootUrl || '/atlas'}/${props.resource.uriKey}`, query, {
54
+ preserveState: true,
55
+ preserveScroll: true,
56
+ })
57
+ }
58
+
59
+ function onSearch(val: string) {
60
+ search.value = val
61
+ navigate({ search: val, page: 1 })
62
+ }
63
+
64
+ function onSort(field: string) {
65
+ const order =
66
+ props.filters.sort === field && props.filters.order === 'asc'
67
+ ? 'desc'
68
+ : 'asc'
69
+ navigate({ sort: field, order })
70
+ }
71
+
72
+ function onPage(page: number) {
73
+ navigate({ page })
74
+ }
75
+
76
+ function onEdit(id: number | string) {
77
+ router.get(`${props.rootUrl || '/atlas'}/${props.resource.uriKey}/${id}/edit`)
78
+ }
79
+
80
+ function onDelete(id: number | string) {
81
+ if (!confirm('Are you sure you want to delete this record?')) return
82
+
83
+ // Use rootUrl/api/resource/id
84
+ const apiBase = props.rootUrl ? `${props.rootUrl}/api` : '/atlas/api'
85
+ fetch(`${apiBase}/${props.resource.uriKey}/${id}`, {
86
+ method: 'DELETE',
87
+ headers: { 'Accept': 'application/json' },
88
+ })
89
+ .then((r) => {
90
+ if (r.ok) {
91
+ showToast('Record deleted successfully')
92
+ router.reload()
93
+ } else {
94
+ showToast('Failed to delete record', 'error')
95
+ }
96
+ })
97
+ .catch(() => showToast('Failed to delete record', 'error'))
98
+ }
99
+ </script>
100
+
101
+ <template>
102
+ <Layout
103
+ :navigation="navigation"
104
+ :resource-title="resource.title"
105
+ :breadcrumbs="[{ label: resource.title }]"
106
+ :root-url="rootUrl"
107
+ >
108
+ <div class="atlas-page-header">
109
+ <h1 class="atlas-page-header__title">{{ resource.title }}</h1>
110
+ <div class="atlas-page-header__actions">
111
+ <SearchBar :modelValue="search" @update:modelValue="onSearch" />
112
+ <Link :href="`${rootUrl || '/atlas'}/${resource.uriKey}/create`" class="atlas-btn atlas-btn--primary">
113
+ + Create {{ resource.title }}
114
+ </Link>
115
+ </div>
116
+ </div>
117
+
118
+ <DataTable
119
+ :rows="data"
120
+ :sort="filters.sort"
121
+ :order="filters.order"
122
+ @sort="onSort"
123
+ @edit="onEdit"
124
+ @delete="onDelete"
125
+ >
126
+ <template #footer>
127
+ <Pagination :meta="meta" @page="onPage" />
128
+ </template>
129
+ </DataTable>
130
+
131
+ <!-- Toast -->
132
+ <Teleport to="body">
133
+ <div v-if="toast" class="atlas-toast" :class="`atlas-toast--${toast.type}`">
134
+ {{ toast.message }}
135
+ </div>
136
+ </Teleport>
137
+ </Layout>
138
+ </template>
@@ -0,0 +1,9 @@
1
+ import "../chunk-7QVYU63E.js";
2
+ import MakeResource from "./make_resource.js";
3
+ var main_default = [
4
+ MakeResource
5
+ ];
6
+ export {
7
+ main_default as default
8
+ };
9
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../commands/main.ts"],"sourcesContent":["import MakeResource from './make_resource.js'\n\nexport default [\n MakeResource,\n]\n"],"mappings":";AAAA,OAAOA,kBAAkB;AAEzB,IAAA,eAAe;EACbA;;","names":["MakeResource"]}
@@ -0,0 +1,42 @@
1
+ import {
2
+ __name
3
+ } from "../chunk-7QVYU63E.js";
4
+ function _ts_decorate(decorators, target, key, desc) {
5
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
6
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
7
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
8
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
9
+ }
10
+ __name(_ts_decorate, "_ts_decorate");
11
+ function _ts_metadata(k, v) {
12
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
13
+ }
14
+ __name(_ts_metadata, "_ts_metadata");
15
+ import { BaseCommand, args } from "@adonisjs/core/ace";
16
+ import { stubsRoot } from "../stubs/main.js";
17
+ class MakeResource extends BaseCommand {
18
+ static {
19
+ __name(this, "MakeResource");
20
+ }
21
+ static commandName = "make:atlas:resource";
22
+ static description = "Create a new Atlas resource class";
23
+ static options = {
24
+ startApp: true
25
+ };
26
+ async run() {
27
+ const codemods = await this.createCodemods();
28
+ await codemods.makeUsingStub(stubsRoot, "resource.stub", {
29
+ name: this.name
30
+ });
31
+ }
32
+ }
33
+ _ts_decorate([
34
+ args.string({
35
+ description: "The name of the resource (e.g. User)"
36
+ }),
37
+ _ts_metadata("design:type", String)
38
+ ], MakeResource.prototype, "name", void 0);
39
+ export {
40
+ MakeResource as default
41
+ };
42
+ //# sourceMappingURL=make_resource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../commands/make_resource.ts"],"sourcesContent":["import { BaseCommand, args } from '@adonisjs/core/ace'\nimport { CommandOptions } from '@adonisjs/core/types/ace'\nimport { stubsRoot } from '../stubs/main.js'\n\nexport default class MakeResource extends BaseCommand {\n static commandName = 'make:atlas:resource'\n static description = 'Create a new Atlas resource class'\n\n @args.string({ description: 'The name of the resource (e.g. User)' })\n declare name: string\n\n static options: CommandOptions = {\n startApp: true,\n }\n\n async run() {\n const codemods = await this.createCodemods()\n\n await codemods.makeUsingStub(stubsRoot, 'resource.stub', {\n name: this.name,\n })\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA,SAASA,aAAaC,YAAY;AAElC,SAASC,iBAAiB;AAE1B,MAAA,qBAA0CF,YAAAA;SAAAA;;;EACxC,OAAOG,cAAc;EACrB,OAAOC,cAAc;EAKrB,OAAOC,UAA0B;IAC/BC,UAAU;EACZ;EAEA,MAAMC,MAAM;AACV,UAAMC,WAAW,MAAM,KAAKC,eAAc;AAE1C,UAAMD,SAASE,cAAcR,WAAW,iBAAiB;MACvDS,MAAM,KAAKA;IACb,CAAA;EACF;AACF;;OAdQC,OAAAA;IAASR,aAAa;;;;","names":["BaseCommand","args","stubsRoot","commandName","description","options","startApp","run","codemods","createCodemods","makeUsingStub","name","string"]}
@@ -0,0 +1,17 @@
1
+ import {
2
+ __name
3
+ } from "./chunk-7QVYU63E.js";
4
+ import { stubsRoot } from "./stubs/main.js";
5
+ async function configure(command) {
6
+ const codemods = await command.createCodemods();
7
+ await codemods.updateRcFile((rc) => {
8
+ rc.addProvider("adonis-atlas/atlas_provider");
9
+ rc.addCommand("adonis-atlas/commands");
10
+ });
11
+ await codemods.makeUsingStub(stubsRoot, "config.stub", {});
12
+ }
13
+ __name(configure, "configure");
14
+ export {
15
+ configure
16
+ };
17
+ //# sourceMappingURL=configure.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../configure.ts"],"sourcesContent":["import ConfigureCommand from '@adonisjs/core/commands/configure'\nimport { stubsRoot } from './stubs/main.js'\n\n/**\n * Configures the package\n */\nexport async function configure(command: ConfigureCommand) {\n const codemods = await command.createCodemods()\n\n // params: (providerPath, layer)\n // layer: 'app' | 'router' | 'server' | 'test' ... usually 'app' or unspecified?\n // Adonis 6: await codemods.updateRcFile((rc) => { rc.addProvider(...) })\n\n await codemods.updateRcFile((rc) => {\n rc.addProvider('adonis-atlas/atlas_provider')\n rc.addCommand('adonis-atlas/commands')\n })\n\n await codemods.makeUsingStub(stubsRoot, 'config.stub', {})\n}\n"],"mappings":";;;AACA,SAASA,iBAAiB;AAK1B,eAAsBC,UAAUC,SAAyB;AACvD,QAAMC,WAAW,MAAMD,QAAQE,eAAc;AAM7C,QAAMD,SAASE,aAAa,CAACC,OAAAA;AAC3BA,OAAGC,YAAY,6BAAA;AACfD,OAAGE,WAAW,uBAAA;EAChB,CAAA;AAEA,QAAML,SAASM,cAAcT,WAAW,eAAe,CAAC,CAAA;AAC1D;AAbsBC;","names":["stubsRoot","configure","command","codemods","createCodemods","updateRcFile","rc","addProvider","addCommand","makeUsingStub"]}
package/build/index.js ADDED
@@ -0,0 +1,29 @@
1
+ import {
2
+ __name
3
+ } from "./chunk-7QVYU63E.js";
4
+ import "./src/types.js";
5
+ import { Atlas } from "./src/atlas.js";
6
+ import { Resource } from "./src/resource.js";
7
+ import { ResourceRegistry } from "./src/resource_registry.js";
8
+ export * from "./src/fields/index.js";
9
+ export * from "./src/http/controllers/resource_controller.js";
10
+ import { registerAtlasRoutes } from "./src/http/register_routes.js";
11
+ export * from "./src/http/resource_query_builder.js";
12
+ import { default as default2 } from "./commands/make_resource.js";
13
+ import { default as default3 } from "./providers/atlas_provider.js";
14
+ import { configure } from "./configure.js";
15
+ function defineConfig(config) {
16
+ return config;
17
+ }
18
+ __name(defineConfig, "defineConfig");
19
+ export {
20
+ Atlas,
21
+ default3 as AtlasProvider,
22
+ default2 as MakeResource,
23
+ Resource,
24
+ ResourceRegistry,
25
+ configure,
26
+ defineConfig,
27
+ registerAtlasRoutes
28
+ };
29
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../index.ts"],"sourcesContent":["import './src/types.js'\nexport { Atlas } from './src/atlas.js'\nexport { Resource } from './src/resource.js'\nexport { ResourceRegistry } from './src/resource_registry.js'\nexport * from './src/fields/index.js'\nexport * from './src/http/controllers/resource_controller.js'\nexport { registerAtlasRoutes } from './src/http/register_routes.js'\nexport * from './src/http/resource_query_builder.js'\nexport { default as MakeResource } from './commands/make_resource.js'\nexport { default as AtlasProvider } from './providers/atlas_provider.js'\nimport { AtlasConfig } from './src/types.js'\n\nexport { configure } from './configure.js'\n\n/**\n * Define the configuration for Atlas\n */\nexport function defineConfig(config: AtlasConfig) {\n return config\n}\n"],"mappings":";;;AAAA,OAAO;AACP,SAASA,aAAa;AACtB,SAASC,gBAAgB;AACzB,SAASC,wBAAwB;AACjC,cAAc;AACd,cAAc;AACd,SAASC,2BAA2B;AACpC,cAAc;AACd,SAAoBC,WAAXC,gBAA+B;AACxC,SAAoBC,WAAXD,gBAAgC;AAGzC,SAASE,iBAAiB;AAKnB,SAASC,aAAaC,QAAmB;AAC9C,SAAOA;AACT;AAFgBD;","names":["Atlas","Resource","ResourceRegistry","registerAtlasRoutes","MakeResource","default","AtlasProvider","configure","defineConfig","config"]}
@@ -0,0 +1,56 @@
1
+ import {
2
+ __name
3
+ } from "../chunk-7QVYU63E.js";
4
+ class AtlasProvider {
5
+ static {
6
+ __name(this, "AtlasProvider");
7
+ }
8
+ app;
9
+ constructor(app) {
10
+ this.app = app;
11
+ }
12
+ /**
13
+ * Register bindings to the container
14
+ */
15
+ register() {
16
+ this.app.container.singleton("atlas.registry", async () => {
17
+ const { ResourceRegistry } = await import("../src/resource_registry.js");
18
+ return new ResourceRegistry();
19
+ });
20
+ this.app.container.singleton("atlas", async () => {
21
+ const { Atlas } = await import("../src/atlas.js");
22
+ return new Atlas(this.app);
23
+ });
24
+ }
25
+ /**
26
+ * The container bindings have booted
27
+ */
28
+ async boot() {
29
+ const config = this.app.config;
30
+ const mountRoutes = config.get("atlas.mountRoutes", true);
31
+ if (mountRoutes) {
32
+ const { registerAtlasRoutes } = await import("../src/http/register_routes.js");
33
+ const router = await this.app.container.make("router");
34
+ registerAtlasRoutes(void 0, router, config);
35
+ }
36
+ }
37
+ /**
38
+ * The application has been booted
39
+ */
40
+ async start() {
41
+ }
42
+ /**
43
+ * The process has been started
44
+ */
45
+ async ready() {
46
+ }
47
+ /**
48
+ * Preparing to shutdown the app
49
+ */
50
+ async shutdown() {
51
+ }
52
+ }
53
+ export {
54
+ AtlasProvider as default
55
+ };
56
+ //# sourceMappingURL=atlas_provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../providers/atlas_provider.ts"],"sourcesContent":["import { ApplicationService } from '@adonisjs/core/types'\n\nexport default class AtlasProvider {\n constructor(protected app: ApplicationService) { }\n\n /**\n * Register bindings to the container\n */\n register() {\n this.app.container.singleton('atlas.registry', async () => {\n const { ResourceRegistry } = await import('../src/resource_registry.js')\n return new ResourceRegistry()\n })\n\n this.app.container.singleton('atlas', async () => {\n const { Atlas } = await import('../src/atlas.js')\n return new Atlas(this.app)\n })\n }\n\n /**\n * The container bindings have booted\n */\n async boot() {\n const config = this.app.config\n const mountRoutes = config.get('atlas.mountRoutes', true)\n\n if (mountRoutes) {\n const { registerAtlasRoutes } = await import('../src/http/register_routes.js')\n const router = await this.app.container.make('router')\n registerAtlasRoutes(undefined, router, config)\n }\n }\n\n /**\n * The application has been booted\n */\n async start() {\n //\n }\n\n /**\n * The process has been started\n */\n async ready() {\n //\n }\n\n /**\n * Preparing to shutdown the app\n */\n async shutdown() {\n //\n }\n}\n"],"mappings":";;;AAEA,MAAA,cAAqBA;EAArB,OAAqBA;;;;EACnBC,YAAsBC,KAAyB;SAAzBA,MAAAA;EAA2B;;;;EAKjDC,WAAW;AACT,SAAKD,IAAIE,UAAUC,UAAU,kBAAkB,YAAA;AAC7C,YAAM,EAAEC,iBAAgB,IAAK,MAAM,OAAO,6BAAA;AAC1C,aAAO,IAAIA,iBAAAA;IACb,CAAA;AAEA,SAAKJ,IAAIE,UAAUC,UAAU,SAAS,YAAA;AACpC,YAAM,EAAEE,MAAK,IAAK,MAAM,OAAO,iBAAA;AAC/B,aAAO,IAAIA,MAAM,KAAKL,GAAG;IAC3B,CAAA;EACF;;;;EAKA,MAAMM,OAAO;AACX,UAAMC,SAAS,KAAKP,IAAIO;AACxB,UAAMC,cAAcD,OAAOE,IAAI,qBAAqB,IAAA;AAEpD,QAAID,aAAa;AACf,YAAM,EAAEE,oBAAmB,IAAK,MAAM,OAAO,gCAAA;AAC7C,YAAMC,SAAS,MAAM,KAAKX,IAAIE,UAAUU,KAAK,QAAA;AAC7CF,0BAAoBG,QAAWF,QAAQJ,MAAAA;IACzC;EACF;;;;EAKA,MAAMO,QAAQ;EAEd;;;;EAKA,MAAMC,QAAQ;EAEd;;;;EAKA,MAAMC,WAAW;EAEjB;AACF;","names":["AtlasProvider","constructor","app","register","container","singleton","ResourceRegistry","Atlas","boot","config","mountRoutes","get","registerAtlasRoutes","router","make","undefined","start","ready","shutdown"]}
@@ -0,0 +1,18 @@
1
+ {{{
2
+ exports({
3
+ to: app.configPath('atlas.ts')
4
+ })
5
+ }}}
6
+ import { defineConfig } from 'adonis-atlas'
7
+
8
+ export default defineConfig({
9
+ /**
10
+ * The prefix for Atlas routes
11
+ */
12
+ prefix: '/atlas',
13
+
14
+ /**
15
+ * Whether to automatically mount routes
16
+ */
17
+ mountRoutes: true,
18
+ })
@@ -0,0 +1,25 @@
1
+ {{{
2
+ exports({
3
+ to: app.makePath('app/atlas/resources', string(name).snakeCase() + '_resource.ts')
4
+ })
5
+ }}}
6
+ import { Resource } from 'adonis-atlas'
7
+ import { TextField, DateTimeField } from 'adonis-atlas'
8
+ import {{ name }} from '#models/{{ string(name).snakeCase() }}'
9
+
10
+ export default class {{ name }}Resource extends Resource {
11
+ static model = {{ name }}
12
+ static title = '{{ string(name).plural() }}'
13
+
14
+ fields() {
15
+ return [
16
+ TextField.make('id').sortable(),
17
+
18
+ // TODO: Add your fields here
19
+
20
+ DateTimeField.make('createdAt')
21
+ .label('Created At')
22
+ .sortable(),
23
+ ]
24
+ }
25
+ }