@orieljs/framework 0.1.0-alpha.14 → 0.1.0-alpha.16

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 (70) hide show
  1. package/dist/{chunk-X4N74JDO.js → chunk-3QHTNAMZ.js} +6 -4
  2. package/dist/{chunk-X4N74JDO.js.map → chunk-3QHTNAMZ.js.map} +1 -1
  3. package/dist/{chunk-BKA5F3TH.js → chunk-6AXJB4CD.js} +5 -1
  4. package/dist/chunk-6AXJB4CD.js.map +1 -0
  5. package/dist/{chunk-UBSIBGXR.js → chunk-MG4YEWMV.js} +1351 -497
  6. package/dist/chunk-MG4YEWMV.js.map +1 -0
  7. package/dist/{chunk-4NCMY3ZS.js → chunk-YNDMTTWL.js} +121 -8
  8. package/dist/chunk-YNDMTTWL.js.map +1 -0
  9. package/dist/contracts.d.ts +112 -1
  10. package/dist/contracts.js +5 -1
  11. package/dist/{index.d-lffxurFs.d.ts → index.d-DA-Iu2a2.d.ts} +39 -2
  12. package/dist/index.d.ts +2838 -2101
  13. package/dist/index.js +1805 -647
  14. package/dist/index.js.map +1 -1
  15. package/dist/{jsx-runtime-Bc5KJzwb.d.ts → jsx-runtime-CenT41Y0.d.ts} +1 -1
  16. package/dist/jsx-runtime.d.ts +2 -2
  17. package/dist/jsx-runtime.js +3 -3
  18. package/dist/{testing-CVpo7aRl.d.ts → testing-B8J_HhF4.d.ts} +6 -2
  19. package/dist/testing.d.ts +2 -2
  20. package/dist/testing.js +3 -3
  21. package/docs/authentication.md +45 -3
  22. package/docs/authorization.md +2 -4
  23. package/docs/cache.md +29 -5
  24. package/docs/configuration.md +84 -7
  25. package/docs/console.md +41 -2
  26. package/docs/container.md +4 -0
  27. package/docs/csrf.md +2 -2
  28. package/docs/database.md +27 -2
  29. package/docs/deployment.md +42 -18
  30. package/docs/eloquent-factories.md +7 -3
  31. package/docs/eloquent-mutators.md +2 -1
  32. package/docs/eloquent-observers.md +2 -0
  33. package/docs/eloquent-relationships.md +34 -1
  34. package/docs/eloquent-resources.md +253 -0
  35. package/docs/eloquent.md +47 -0
  36. package/docs/errors.md +12 -3
  37. package/docs/events.md +3 -1
  38. package/docs/export.md +3 -3
  39. package/docs/facades.md +1 -0
  40. package/docs/helpers.md +33 -2
  41. package/docs/inertia.md +11 -1
  42. package/docs/installation.md +6 -2
  43. package/docs/laravel.md +71 -0
  44. package/docs/lifecycle.md +9 -5
  45. package/docs/live.md +88 -8
  46. package/docs/mail.md +32 -5
  47. package/docs/middleware.md +20 -12
  48. package/docs/navigation.json +12 -0
  49. package/docs/notifications.md +22 -0
  50. package/docs/pagination.md +4 -0
  51. package/docs/passwords.md +4 -6
  52. package/docs/providers.md +4 -6
  53. package/docs/queues.md +70 -2
  54. package/docs/requests.md +42 -3
  55. package/docs/responses.md +9 -5
  56. package/docs/routing.md +118 -7
  57. package/docs/scheduling.md +27 -0
  58. package/docs/session.md +2 -2
  59. package/docs/starter-kits.md +26 -7
  60. package/docs/storage.md +10 -4
  61. package/docs/testing.md +10 -2
  62. package/docs/two-factor.md +38 -4
  63. package/docs/upgrade.md +182 -0
  64. package/docs/validation.md +70 -9
  65. package/docs/views.md +1 -0
  66. package/docs/vite.md +20 -1
  67. package/package.json +43 -35
  68. package/dist/chunk-4NCMY3ZS.js.map +0 -1
  69. package/dist/chunk-BKA5F3TH.js.map +0 -1
  70. package/dist/chunk-UBSIBGXR.js.map +0 -1
@@ -1,8 +1,11 @@
1
1
  import {
2
2
  Application,
3
3
  ConfigRepository,
4
- Container
5
- } from "./chunk-BKA5F3TH.js";
4
+ Container,
5
+ ExceptionHandler,
6
+ HttpRequest,
7
+ LogManager
8
+ } from "./chunk-6AXJB4CD.js";
6
9
 
7
10
  // ../Container/dist/index.js
8
11
  import { AsyncLocalStorage } from "async_hooks";
@@ -973,10 +976,10 @@ var Collection = class _Collection {
973
976
  * negative or fractional index throws a RangeError, as put() does.
974
977
  */
975
978
  replace(items) {
976
- const copy = this.newInstance(this.items);
979
+ const copy2 = this.newInstance(this.items);
977
980
  const entries = Symbol.iterator in items ? [...items].map((value2, index) => [index, value2]) : Object.entries(items).map(([index, value2]) => [Number(index), value2]);
978
- for (const [index, value2] of [...entries].sort((a, b) => a[0] - b[0])) copy.put(index, value2);
979
- return copy;
981
+ for (const [index, value2] of [...entries].sort((a, b) => a[0] - b[0])) copy2.put(index, value2);
982
+ return copy2;
980
983
  }
981
984
  // ---------------------------------------------------------------- building collections
982
985
  /** One level of nested arrays and collections, merged (other items are dropped). */
@@ -2963,6 +2966,91 @@ var Arr = {
2963
2966
  return index === -1 ? defaultValue : items[index];
2964
2967
  }
2965
2968
  };
2969
+ function serializeDate(date) {
2970
+ return date.toISOString().replace(/\.(\d{3})Z$/, ".$1000Z");
2971
+ }
2972
+ var flatKeys = (keys) => keys.flatMap((key) => typeof key === "string" ? [key] : [...key]);
2973
+ var isPlainObject = (value2) => {
2974
+ if (typeof value2 !== "object" || value2 === null) return false;
2975
+ const prototype = Object.getPrototypeOf(value2);
2976
+ return prototype === Object.prototype || prototype === null;
2977
+ };
2978
+ function copy(value2) {
2979
+ if (Array.isArray(value2)) return value2.map(copy);
2980
+ if (isPlainObject(value2)) return Object.fromEntries(Object.entries(value2).map(([key, item]) => [key, copy(item)]));
2981
+ return value2;
2982
+ }
2983
+ var ValidatedInput = class _ValidatedInput {
2984
+ #input;
2985
+ constructor(input) {
2986
+ this.#input = input;
2987
+ }
2988
+ all() {
2989
+ return copy(this.#input);
2990
+ }
2991
+ /** The keys given that are there, as `{ key: value }`; a dotted key is nested. */
2992
+ only(...keys) {
2993
+ const results = {};
2994
+ for (const key of flatKeys(keys)) if (Arr.has(this.#input, key)) Arr.set(results, key, copy(Arr.get(this.#input, key)));
2995
+ return results;
2996
+ }
2997
+ /** Everything but the keys given. */
2998
+ except(...keys) {
2999
+ const results = this.all();
3000
+ for (const key of flatKeys(keys)) Arr.forget(results, key);
3001
+ return results;
3002
+ }
3003
+ /** A new input with the values added (replacing the keys they share). */
3004
+ merge(values) {
3005
+ return new _ValidatedInput({ ...this.all(), ...values });
3006
+ }
3007
+ /** Laravel's collect(), as a list: the input's values, or those of the list (or object) at `key`; a value alone is a list of one. */
3008
+ collect(key) {
3009
+ const value2 = key === void 0 ? this.#input : Arr.get(this.#input, key);
3010
+ if (value2 === void 0 || value2 === null) return [];
3011
+ if (Array.isArray(value2)) return copy(value2);
3012
+ if (isPlainObject(value2)) return Object.values(copy(value2));
3013
+ return [value2];
3014
+ }
3015
+ /** Whether every key given is there. */
3016
+ has(...keys) {
3017
+ return flatKeys(keys).every((key) => Arr.has(this.#input, key));
3018
+ }
3019
+ /** The value at `key` (dotted or not), else `defaultValue`; everything without a key. */
3020
+ input(key, defaultValue) {
3021
+ return key === void 0 ? this.all() : copy(Arr.get(this.#input, key, defaultValue));
3022
+ }
3023
+ };
3024
+ var HIDDEN_SEGMENT = /^\.|\.(ts|tsx|mts|cts)$|[. ]$/i;
3025
+ var PUBLISHED_DOTFILES = /* @__PURE__ */ new Set([".well-known", ".nojekyll"]);
3026
+ function isPublicAsset(relativePath) {
3027
+ const segments2 = relativePath.split(/[\\/]/).filter((segment) => segment !== "");
3028
+ return !segments2.some((segment, index) => HIDDEN_SEGMENT.test(segment) && !(index === 0 && PUBLISHED_DOTFILES.has(segment)));
3029
+ }
3030
+ var warned = /* @__PURE__ */ new WeakMap();
3031
+ var quiet = 0;
3032
+ function warnProcessWide(what, hint) {
3033
+ if (quiet > 0) return;
3034
+ const scope = currentContainer();
3035
+ if (scope === void 0 || !scope.bound(HttpRequest) || !scope.bound(Application)) return;
3036
+ const app2 = scope.make(Application);
3037
+ if (!app2.environment("local")) return;
3038
+ let seen = warned.get(app2);
3039
+ if (seen === void 0) warned.set(app2, seen = /* @__PURE__ */ new Set());
3040
+ if (seen.has(what)) return;
3041
+ seen.add(what);
3042
+ const message = `${what} inside a request changes it for every request, not only this one: ${hint}.`;
3043
+ if (scope.bound(LogManager)) scope.make(LogManager).warning(message);
3044
+ else console.warn(message);
3045
+ }
3046
+ function withoutProcessWideWarnings(fn) {
3047
+ quiet++;
3048
+ try {
3049
+ return fn();
3050
+ } finally {
3051
+ quiet--;
3052
+ }
3053
+ }
2966
3054
  var ServiceProvider = class {
2967
3055
  constructor(app2) {
2968
3056
  this.app = app2;
@@ -2975,7 +3063,7 @@ var ServiceProvider = class {
2975
3063
  /** Package defaults under `key`; values the app already set win (shallow merge, like Laravel). */
2976
3064
  mergeConfigFrom(defaults, key) {
2977
3065
  const config2 = this.app.make(ConfigRepository);
2978
- config2.set(key, { ...defaults, ...config2.get(key, {}) });
3066
+ withoutProcessWideWarnings(() => config2.set(key, { ...defaults, ...config2.get(key, {}) }));
2979
3067
  }
2980
3068
  };
2981
3069
  function facade(abstract, extras) {
@@ -3073,6 +3161,7 @@ var ClassRegistry = class {
3073
3161
  }
3074
3162
  };
3075
3163
  var SCOPE_METHODS = /* @__PURE__ */ new Set(["make", "instance", "bound", "resolved", "forgetInstance", "createScope", "run"]);
3164
+ var PROCESS_WIDE_METHODS = /* @__PURE__ */ new Set(["bind", "singleton", "extend"]);
3076
3165
  var scopedViews = /* @__PURE__ */ new WeakMap();
3077
3166
  function viewFrom(scope, application) {
3078
3167
  let view = scopedViews.get(scope);
@@ -3081,7 +3170,12 @@ function viewFrom(scope, application) {
3081
3170
  get(target, property) {
3082
3171
  const source = SCOPE_METHODS.has(property) ? scope : target;
3083
3172
  const member = Reflect.get(source, property, source);
3084
- return typeof member === "function" ? member.bind(source) : member;
3173
+ if (typeof member !== "function") return member;
3174
+ if (!PROCESS_WIDE_METHODS.has(property)) return member.bind(source);
3175
+ return (...args) => {
3176
+ warnProcessWide(`app().${String(property)}()`, "app().instance() binds for this request");
3177
+ return member.apply(source, args);
3178
+ };
3085
3179
  }
3086
3180
  });
3087
3181
  scopedViews.set(scope, view);
@@ -3118,6 +3212,19 @@ async function retry(times, fn, sleepMs = 0, when) {
3118
3212
  }
3119
3213
  }
3120
3214
  }
3215
+ async function report(error) {
3216
+ const container = currentContainer();
3217
+ if (container !== void 0 && container.bound(ExceptionHandler)) await container.make(ExceptionHandler).report(error);
3218
+ else console.error(error);
3219
+ }
3220
+ async function rescue(callback, rescue2, shouldReport = true) {
3221
+ try {
3222
+ return await callback();
3223
+ } catch (error) {
3224
+ if (typeof shouldReport === "function" ? shouldReport(error) : shouldReport) await report(error);
3225
+ return typeof rescue2 === "function" ? await rescue2(error) : rescue2;
3226
+ }
3227
+ }
3121
3228
  var LINES = {
3122
3229
  "auth.failed": "These credentials do not match our records.",
3123
3230
  "auth.password": "The provided password is incorrect.",
@@ -3262,6 +3369,10 @@ export {
3262
3369
  Stringable,
3263
3370
  Str,
3264
3371
  Arr,
3372
+ serializeDate,
3373
+ ValidatedInput,
3374
+ isPublicAsset,
3375
+ warnProcessWide,
3265
3376
  ServiceProvider,
3266
3377
  facade,
3267
3378
  MissingPackageError,
@@ -3273,6 +3384,8 @@ export {
3273
3384
  value,
3274
3385
  tap,
3275
3386
  retry,
3387
+ report,
3388
+ rescue,
3276
3389
  __,
3277
3390
  fileType_exports
3278
3391
  };
@@ -3296,4 +3409,4 @@ export {
3296
3409
  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
3297
3410
  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3298
3411
  */
3299
- //# sourceMappingURL=chunk-4NCMY3ZS.js.map
3412
+ //# sourceMappingURL=chunk-YNDMTTWL.js.map